AES-128-CFB加密算法问题
我现在用的是Crypto插件的AES/CFB/NoPadding,项目要求是要把6个单字节的16进制字节集作为明文,然后16个单字节的16进制字节集作为key,16个单字节的16进制字符集作为iv 但是,,,,,,测试了好久发现都是加密结果对不上,解密结果却是正确的!! 附上代码: [代码]var[代码] [代码]text = crypto.Utf8.parse(String.fromCharCode(0x11, 0x22, 0x33, 0x44, 0x55, 0x66));[代码][代码]console.log([代码][代码]'----------------------------------------------------------明文:'[代码][代码], text);[代码] [代码]var[代码] [代码]keys = hexMD5(String.fromCharCode(0xBC, 0x9A, 0x78, 0x56, 0x34, 0x12));[代码][代码]var[代码] [代码]XMD5Keys = crypto.Utf8.parse(String.fromCharCode([代码][代码]this[代码][代码].DEE(keys)));[代码][代码]console.log([代码][代码]'----------------------------------------------------------密钥:'[代码][代码], XMD5Keys);[代码] [代码]var[代码] [代码]iv = hexMD5(String.fromCharCode(0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xef,0xcd,0xab,0x89,0x67,0x45,0x23,0x01));[代码][代码]var[代码] [代码]EMD5iv = crypto.Utf8.parse(String.fromCharCode([代码][代码]this[代码][代码].DEE(iv)));[代码][代码]console.log([代码][代码]'----------------------------------------------------------向量:'[代码][代码], EMD5iv);[代码] [代码]var[代码] [代码]mi = [代码][代码]new[代码] [代码]crypto.AES().encrypt(text, XMD5Keys, {iv: EMD5iv,mode: crypto.Mode.CFB,padding: crypto.Padding.NoPadding});[代码][代码]console.log([代码][代码]'----------------------------------------------------------加密:'[代码][代码], [代码][代码]this[代码][代码].DEE(mi.ciphertext.toString()));[代码] [代码]var[代码] [代码]v = [代码][代码]new[代码] [代码]crypto.AES().decrypt(mi.toString(), XMD5Keys, {iv: EMD5iv,mode: crypto.Mode.CFB, padding: crypto.Padding.NoPadding});[代码][代码]console.log([代码][代码]'----------------------------------------------------------解密:'[代码][代码], [代码][代码]this[代码][代码].DEE(v.toString()));[代码] 有酬谢!