前端常用的加密方法
1.base64加密:
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>base64加密</title> 6 <script type="text/javascript" src="base64.js"></script> 7 <script type="text/javascript"> 8 var b = new Base64(); 9 var str = b.encode("admin:admin"); 10 alert("base64 encode:" + str); 11 //解密 12 str = b.decode(str); 13 alert("base64 decode:" + str); 14 </script> 15 </head> 16 17 <body> 18 </body> 19 </html>
2.md5加密:
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>md5加密</title> 6 <script type="text/ecmascript" src="md5.js"></script> 7 <script type="text/javascript"> 8 var hash = hex_md5("123dafd"); 9 alert(hash) 10 </script> 11 </head> 12 13 <body> 14 </body> 15 </html>
3.sha1加密:
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>sha1加密</title> 6 <script type="text/ecmascript" src="sha1.js"></script> 7 <script type="text/javascript"> 8 var sha = hex_sha1('mima123465') 9 alert(sha) 10 </script> 11 </head> 12 13 <body> 14 </body> 15 </html>
一辈子很短,努力的做好两件事就好;第一件事是热爱生活,好好的去爱身边的人;第二件事是努力学习,在工作中取得不一样的成绩,实现自己的价值,而不是仅仅为了赚钱;