//Call the functions
string EncryptedString= GetEncryptedText("Chandru");
string DecryptedString = GetDecryptedText(EncryptedString);
//Create an object for RSACryptoServiceProvider
RSACryptoServiceProvider RSAEncrypt = new RSACryptoServiceProvider();
//Encrypt the String Provided
public string GetEncryptedText(string PlainStringToEncrypt)
{
return Encoding.Default.GetString(RSAEncrypt.Encrypt(Encoding.Default.GetBytes(PlainStringToEncrypt), false));
}
//Decrypt The String Provided
public string GetDecryptedText(string EncryptedStringToDecrypt)
{
return Encoding.Default.GetString(RSAEncrypt.Decrypt(Encoding.Default.GetBytes(EncryptedStringToDecrypt), false));
}
No comments:
Post a Comment