生成iv时出现crypto.createDecipheriv错误
我使用crypto.createDecipheriv有一个非常奇怪的错误
在定义下面的代码时:
var decipher = crypto.createDecipheriv('aes-256-cbc', '3dc837d877144001c1291fdda417903d9130aeac', '1234567890123456');
和请求到达这一行我马上得到一个错误,崩溃我的应用程序:
Error: Invalid key length at Error (native) at new Decipheriv (crypto.js:282:16) at Object.Decipheriv (crypto.js:279:12)
有没有人知道这可能是什么原因造成的?
谢谢。
你的钥匙长度太短。 aes-256-cbc
需要一个256位的密钥,意思是32个字节。 但是,您提供的(hex)键只有20个字节。
另外,你需要使用new Buffer('myhexkey', 'hex')
作为关键参数,以便对hex字节进行解码。
- 阅读Java中的encryption密码
- 使用node-jose,我如何解密刚encryption的数据?
- 解密来自PHP RIJNDAEL_128 CBC的node.js中的string
- 如何在nodejs中匹配wordpressencryption的passowrd?
- 尝试在node.js中获取AESencryptionstring以匹配.net中的encryption值
- CryptoSwiftencryption的数据与Node.js不同
- 去朗生成hmac
- 使用phpseclib使用AES进行encryption,并使用CryptoJS进行解密
- 为什么Node.js的符号和CryptographicEngine符号结果有区别?