<!doctype html> <html> <head> <meta charset="utf-8"> <title>crypto-js库常用哈希算法使用示例</title> </head> <body> <script type="text/javascript" src="./crypto-js.min.js"></script> <script type="text/javascript"> var password = 'manong'; console.log("CryptoJS.MD5('" + password + "') <===> " + CryptoJS.MD5(password).toString()); console.log("CryptoJS.SHA1('" + password + "') <===> " + CryptoJS.SHA1(password).toString()); console.log("CryptoJS.SHA224('" + password + "') <===> " + CryptoJS.SHA224(password).toString()); console.log("CryptoJS.SHA256('" + password + "') <===> " + CryptoJS.SHA256(password).toString()); console.log("CryptoJS.SHA384('" + password + "') <===> " + CryptoJS.SHA384(password).toString()); console.log("CryptoJS.SHA512('" + password + "') <===> " + CryptoJS.SHA512(password).toString()); console.log("CryptoJS.SHA3('" + password + "') <===> " + CryptoJS.SHA3(password).toString()); // 说明:CryptoJS.XXX()的返回值是object类型,需要使用toString()转换成字符串。 </script> </body> </html>
Copyright © 2024 码农人生. All Rights Reserved