2

我有以下 C# 代码:

// incoming data - MemoryStream memoryStream
RSACryptoServiceProvider cryptoServiceProvider1 = new RSACryptoServiceProvider();
cryptoServiceProvider1.FromXmlString("<RSAKeyValue><Modulus>...</Modulus><Exponent>AQAB</Exponent><P>...</P><Q>...</Q><DP>...</DP><DQ>...</DQ><InverseQ>...</InverseQ><D>...</D></RSAKeyValue>");
cryptoServiceProvider1.PersistKeyInCsp = true;
RijndaelManaged rijndaelManaged = new RijndaelManaged();
rijndaelManaged.KeySize = 256;
rijndaelManaged.BlockSize = 128;
rijndaelManaged.Mode = CipherMode.CBC;
byte[] numArray3 = new byte[128];
byte[] numArray4 = new byte[16];
// numArray3 & numArray4 - filled with come data;
byte[] rgbKey = cryptoServiceProvider1.Decrypt(numArray3, false);
ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor(rgbKey, numArray4);
CryptoStream cryptoStream = new CryptoStream((Stream) memoryStream, decryptor, CryptoStreamMode.Write);

问题:是否可以将此功能迁移到 node.js (javascript)?

4

1 回答 1

1

我很确定这个Node 模块将能够做你想做的事。

这个 Node 模块为 OpenSSL 的 RSA 公钥/私钥加密功能提供了一套相当完整的包装器。

查看此答案,了解将 XML 密钥转换为 Node 模块可以使用的标准 PEM 密钥的可能方法。

于 2013-09-11T10:51:26.763 回答