小编Ani*_*t B的帖子

在节点中使用aes-256-cbc进行加密时获取无效IV长度的错误

代码示例如下:

  var crypto = require('crypto');
  var key = 'ExchangePasswordPasswordExchange';
  var  plaintext = '150.01';
  var iv = new Buffer(crypto.randomBytes(16))
  ivstring = iv.toString('hex');


  var cipher = crypto.createCipheriv('aes-256-cbc', key, ivstring)
  var  decipher = crypto.createDecipheriv('aes-256-cbc', key,ivstring);

  cipher.update(plaintext, 'utf8', 'base64');
  var encryptedPassword = cipher.final('base64');
Run Code Online (Sandbox Code Playgroud)

获得无效IV长度的错误.

node.js

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

node.js ×1