1、base64:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="base64.js"></script> <title>base64加密</title> </head> <body> <script> var rule = new Base64() var pwd = ‘123456‘ // 加密 var encryption = rule.encode(‘password:‘+pwd) console.log(encryption) //cGFzc3dvcmQ6MTIzNDU2 // 解密 encryption = rule.decode(encryption); console.log(encryption) //password:123456 </script> </body> </html>
2、md5:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="md5.js"></script> <title>md5加密</title> </head> <body> <script> var pwd = ‘123456‘ // 加密 var encryption = hex_md5(‘password:‘+pwd) console.log(encryption) //cc4452544b7f1a162452444f49238de8 </script> </body> </html>
3、sha1
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="sha1.js"></script> <title>sha1加密</title> </head> <body> <script> var pwd = ‘123456‘ // 加密 var encryption = hex_sha1(‘password:‘+pwd) console.log(encryption) //b48d0965a80dfad4ad6db7e98ce666d8226619bb </script> </body> </html>
4、RSA
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="jsencrypt.js"></script> <title>RSA加密</title> </head> <body> <script> var pwd = ‘123456‘ // 加密 var encrypt = new JSEncrypt(); var encryptStr = encrypt.encrypt(‘password :‘+pwd); console.log(encryptStr);//(每次都在变化) // 解密 var decryptStr = encrypt.decrypt(encryptStr); console.log(decryptStr); //password :123456 </script> </body> </html>
原文地址:https://www.cnblogs.com/C-target/p/11335444.html
时间: 2024-10-28 06:18:32