Skip to content

Instantly share code, notes, and snippets.

@rabieedev1996
Created February 19, 2022 18:52
Show Gist options
  • Save rabieedev1996/51c3a2a0f66d724bcc12b4ebca6a9dfa to your computer and use it in GitHub Desktop.
Save rabieedev1996/51c3a2a0f66d724bcc12b4ebca6a9dfa to your computer and use it in GitHub Desktop.
Rsa decryption in c#
public static string Decrypt(string cipherText, string privateKey)
{
UnicodeEncoding _encoder = new UnicodeEncoding();
var rsa = new RSACryptoServiceProvider();
var dataByte= Convert.FromBase64String(cipherText);
rsa.FromXmlString(privateKey);
var decryptedByte = rsa.Decrypt(dataByte, false);
return _encoder.GetString(decryptedByte);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment