javascript AES加密解密,AES/ECB/PKCS7
程序员文章站
2022-03-04 18:24:58
...
<script src="crypto-js.js"></script> <script src="aes.js"></script> <script src="md5.js"></script> <script src="pad-zeropadding.js"></script> <script> var key_hash = CryptoJS.MD5("Message"); var key = CryptoJS.enc.Utf8.parse(key_hash); var iv = ""; var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv,mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7,format:CryptoJS.format.Hex}); document.write("encode:"+encrypted); var dec = CryptoJS.AES.decrypt(encrypted, key, { iv: iv,mode:CryptoJS.mode.ECB,padding:CryptoJS.pad.Pkcs7,format:CryptoJS.format.Hex}); document.write("deccode:"+dec.toString(CryptoJS.enc.Utf8)); </script>