2

I have the following C# code:

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

question: is it possible to migrate this functionality to node.js (javascript)?

CnApTaK
  • 21
  • 1
  • 2

1 Answers1

1

I'm pretty sure this Node module will be able to do what you want.

This Node module provides a fairly complete set of wrappers for the RSA public/private key crypto functionality of OpenSSL.

Take a look at this answer for a possible way of converting the XML key into a standard PEM key that can be used by the Node module.

Community
  • 1
  • 1
  • 2
    I have not found examples of using this module. to start, how to convert the private key of the xml format to one that understands this module? – CnApTaK Sep 11 '13 at 10:58