Node.js 以与SecurityDriven Inferno(C#)相同的方式加密(nodejs)
我需要移植一些加密逻辑,它当前使用库来nodejs。根据文档,“加密”使用AES-256 CTR模式。这是函数签名:Node.js 以与SecurityDriven Inferno(C#)相同的方式加密(nodejs),node.js,encryption,Node.js,Encryption,我需要移植一些加密逻辑,它当前使用库来nodejs。根据文档,“加密”使用AES-256 CTR模式。这是函数签名: public static byte[] Encrypt(byte[] masterKey, ArraySegment<byte> plaintext, ArraySegment<byte>? salt = null) 如果我将未定义或null作为向量传递,则此操作将失败,因为“Missing IV for cipher”可能会在内部生成一个随机IV。此
public static byte[] Encrypt(byte[] masterKey, ArraySegment<byte> plaintext, ArraySegment<byte>? salt = null)
如果我将未定义或null作为向量传递,则此操作将失败,因为“Missing IV for cipher”可能会在内部生成一个随机IV。此外,它不是AES-CTR,而是AES-CTR-HMAC,它还提供密文以及任何附加数据的真实性。IV不应该是秘密的,可以与密文一起发送。你必须弄清楚地狱的序列化格式是什么。
const cipher = crypto.createCipheriv('aes-256-ctr', key, vector);