0

I want to encrypt text with RSA using Public.pem and private.pem

I generated these files with openssl

openssl genrsa -out private.pem 2048

openssl rsa -pubout -in private.pem -out public.pem

I need to encrypt the text in javascript (I use this Library) only for encryption.

This text in base64 is sent to the server in C#, I use RSACryptoServiceProvider, but I only saw that is possible load public key with:

RSAParameters RSAParams = RSA.ExportParameters(false);
RSAParams.Modulus = privateKey;
RSA.ImportParameters(RSAParams);

But I need use my own private.pem file to decrypt my text and use it after.

How can I make this?

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • Unrelated: Since your question is all about the C# part, I'd remove the javascript tags. They are irrelevant. – Fildor Jun 07 '19 at 06:02
  • A quick google for "C# decrypt RSA" popped up several github and other example codes, like this one: https://gist.github.com/gashupl/27e4de6bd8f021f3d61b3122e6bbf775 Can you tell, why they don't work for you? – Fildor Jun 07 '19 at 06:05
  • Because, when I try Encrypt a text with RSA with my pub key in JavaScript with some library (I tried differents) I can't decrypt with C# – Jorge Jun 09 '19 at 04:49

0 Answers0