Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set RSA Parameters

Tags:

c#

rsa

I have been provided with M, Exponent and D components of and RSA parameter and have been trying to encrypt data using it in C#.NET. I was wondering as parts of public key which of these components are necessary to have to encrypt data? Also, the exponent is 10001 in base 16. What should I set the RsaParameters.Exponent parameter in C#? I don't know how exactly I should interpret that number and place it in Exponent which is a byte array. Don't the components need to have an even length in base 16?

Thanks.

like image 426
Hamid Rashidi Avatar asked Jul 04 '26 04:07

Hamid Rashidi


1 Answers

RSAParameters rsaKeyInfo = new RSAParameters
{
   Exponent = new byte[] {1, 0, 1},
   ...
};

using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
    rsa.ImportParameters(rsaKeyInfo);
    rsa.Decrypt(...)
}
like image 89
SkyN Avatar answered Jul 06 '26 19:07

SkyN