【问题标题】:Can someone figure out my encryption secret and iv if they have payload and encrypted string?如果他们有有效载荷和加密字符串,有人可以找出我的加密秘密和 iv 吗?
【发布时间】:2022-12-17 21:29:56
【问题描述】:

我使用 node.js 的 crypto 来编码和解码有效载荷

仅供参考,我是这样做的:

export const encode = (payload) => {
  const cipher = crypto.createCipheriv('aes-256-cbc', env.SECRET, env.IV);
  const encyptedString = cipher.update(JSON.stringify(payload), 'utf-8', 'hex') + cipher.final('hex');

  return encyptedString;
};

export const decode = (encyptedString) => {
  const decipher = crypto.createDecipheriv(
    'aes-256-cbc',
    env.SECRET,
    env.IV,
  );
  const decryptedValue = decipher.update(encyptedString, 'hex', 'utf-8') + decipher.final('utf-8');

  return JSON.parse(decryptedValue);
};

现在,如果有人可以访问有效载荷对象和加密字符串,他们是否能够找出我的env.SECRETenv.IV

【问题讨论】:

    标签: javascript node.js encryption cryptojs


    【解决方案1】:

    不,不可能仅通过有效负载对象和加密字符串来确定,除非您使用非常简单的秘密和像 123456789 这样的 iv,在这种情况下,很容易通过蛮力找出它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-02
      • 1970-01-01
      • 2019-04-17
      • 1970-01-01
      • 2019-02-02
      • 1970-01-01
      相关资源
      最近更新 更多