Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 以与SecurityDriven Inferno(C#)相同的方式加密(nodejs)_Node.js_Encryption - Fatal编程技术网

Node.js 以与SecurityDriven Inferno(C#)相同的方式加密(nodejs)

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。此

我需要移植一些加密逻辑,它当前使用库来nodejs。根据文档,“加密”使用AES-256 CTR模式。这是函数签名:

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);