我现在用的是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())); |
有酬谢!
最近插件页面的相关讨论都打不开,所以没看见。
this.DEE是干嘛的?
感谢您的回复,问题已经解决了,是大小端的问题
没事的,共建生态