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>