<!-- base64加密解密 --> <script type="text/javascript" src="base64.js"></script> <script type="text/javascript"> var b = new Base64(); //加密 var str = b.encode("admin:admin"); alert("base64 encode:" + str); //解密 str = b.decode(str); alert("base64 decode:" + str); </script> <!-- MD5加密 --> <script type="text/ecmascript" src="md5.js"></script> <script type="text/javascript"> var hash = hex_md5("123dafd"); alert(hash); </script> <!-- SHA1加密 --> <script type="text/ecmascript" src="sha1.js"></script> <script type="text/javascript"> var sha = hex_sha1('mima123465'); alert(sha); </script>
附件:
JS实现Base64加密解密、MD5加密、SHA1加密_Attachments.zip