10

在终端中有此警告,在追踪源或实际原因/原因时遇到问题。

(node:37770) Warning: Use Cipheriv for counter mode of aes-256-ctr
(node:37770) Warning: Use Cipheriv for counter mode of aes-256-ctr

不幸的是,没有太多信息可提供。我知道这是 Node 的问题,但不知道如何解决它。https://nodejs.org/api/crypto.html

节点-vstable 8.9.0 (bottled), HEAD

包.json

"dependencies": {
    "axios": "^0.17.0",
    "babel-plugin-wrap-in-js": "^1.1.1",
    "babel-runtime": "^6.26.0",
    "body-parser": "^1.18.2",
    "compression": "^1.7.1",
    "cookie": "^0.3.1",
    "dotenv": "^4.0.0",
    "express": "^4.16.2",
    "express-session": "^1.15.6",
    "firebase": "^4.6.0",
    "firebase-admin": "^5.4.3",
    "isomorphic-unfetch": "^2.0.0",
    "js-cookie": "^2.2.0",
    "lusca": "^1.5.2",
    "next": "^4.1.4",
    "next-redux-wrapper": "^1.3.4",
    "node-sass": "^4.5.3",
    "now-logs": "0.0.7",
    "nprogress": "^0.2.0",
    "orm": "^4.0.1",
    "prop-types": "^15.6.0",
    "raw-loader": "^1.0.0-beta.0",
    "react": "^16.0.0",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-stripe-checkout": "^2.6.3",
    "react-stripe-elements": "^1.2.0",
    "react-transition-group": "^2.2.1",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "sass-loader": "^6.0.6",
    "session-file-store": "^1.1.2",
    "styled-jsx": "^2.1.2",
    "timeme.js": "^2.0.3",
    "uuid": "^3.1.0",
    "webpack": "^3.8.1"
  }
4

4 回答 4

6

用于上述警告用途

var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'test@1234';
var iv = Buffer.from(Array.prototype.map.call(Buffer.alloc(16), () => {return Math.floor(Math.random() * 256)}));
var key = Buffer.concat([Buffer.from(password)], Buffer.alloc(32).length);
var cipher = crypto.createCipheriv(algorithm,password,iv)

在 createCipheriv 方法中,我们需要为 iv 创建一个缓冲区,为包含密码的密钥创建一个缓冲区

代替

var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'test@1234';
var cipher = crypto.createCipher(algorithm,password)

同时将您的数据转换为密码。它将删除警告

于 2019-03-26T05:56:26.960 回答
2

我遇到了类似的问题,在运行了这个 节点问题并查看了本节 的底部之后 ,似乎不建议使用没有随机输入的 aes-256-ctr 来改变它。将此更新为另一种算法后,错误消失了。

如果您不在代码中使用加密,我不确定您的哪些部门可能会抛出此问题。它可能会出现搜索createCipheraes-256-ctr

于 2017-11-03T17:34:42.193 回答
1

你必须使用 createCipheriv 方法

于 2017-12-27T14:58:14.750 回答
1

似乎是与节点 8 和session-file-store模块相关的问题。

https://github.com/valery-barysok/session-file-store/issues/65

于 2017-11-11T11:57:28.733 回答