cryptoJS deciphering/decrypting 消息 AES CFB 模式

cryptoJS deciphering/decrypting messages AES CFB mode

我正在 Ruby 中加密一些字符串,将其发送到客户端并尝试在那里解密字符串。我没有使用 aes 汇总(尽管我尝试过相同的结果)。我已将 aes.js、core.js 和 cipher-core.js 包作为资产包括在内。我检查了 cipher-core.js 中是否存在报告为未找到的函数。我收到错误:

Uncaught TypeError: Cannot read property 'createDecryptor' of undefined
at Object.reset (aes.self-9251f7d….js?body=1:28)
at Object.init (aes.self-9251f7d….js?body=1:25)
at Object.c.hasOwnProperty.c.init (aes.self-9251f7d….js?body=1:8)
at Object.c.hasOwnProperty.c.init (aes.self-9251f7d….js?body=1:8)
at Object.c.hasOwnProperty.c.init (aes.self-9251f7d….js?body=1:8)
at Object.create (aes.self-9251f7d….js?body=1:8)
at Object.createDecryptor (aes.self-9251f7d….js?body=1:25)
at Object.decrypt (aes.self-9251f7d….js?body=1:31)
at Object.decrypt (aes.self-9251f7d….js?body=1:32)
at Object.decrypt (aes.self-9251f7d….js?body=1:26)

代码如下:

function decipher(encipheredMessage, password, iv) {
  var parts = encipheredMessage.split('--', 2),
      enciphered = replaceHex(parts[0])

  deciphered = CryptoJS.AES.decrypt(
    enciphered,
    password,
    { iv: iv,
      mode: CryptoJS.mode.CFB,
      padding: CryptoJS.pad.NoPadding }
    ).toString(CryptoJS.enc.Utf8)

  return deciphered
}

当我将代码加载到节点并为其提供 Ruby 用于加密字符串的 key/iv 时,解密工作。有人知道发生了什么事吗?

编辑

我一直在尝试通过多种方式让它发挥作用。我已经尝试将密钥设为十六进制编码的字符串和十六进制编码的字符数组,但都没有进行任何更改。我真的很难解决这个问题,因为我不是 JS 程序员,none 对 cryptoJS 其他问题的堆栈交换答案似乎适用。

阅读 cryptoJS 源代码后,我发现我需要在我的 application.js 中再包含两个模块,完整的必要 js 文件集是:

cryptoJS/components/aes
cryptoJS/components/core
cryptoJS/components/cipher-core
cryptoJS/components/mode-cfb
cryptoJS/components/pad-(whichever padding used)

aes rollup 没有工作,因为它缺少其中的一些组件,所以我觉得最好单独包含这些组件。