欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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> 

 

相关标签: js AES