Created
February 19, 2022 18:52
-
-
Save rabieedev1996/51c3a2a0f66d724bcc12b4ebca6a9dfa to your computer and use it in GitHub Desktop.
Rsa decryption in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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