javascript AES加密解密,AES/ECB/PKCS7

<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)