Encrypt and Decrypt Using Class

161 Views
  1. public string DecryptString(string encrString)
  2. {
  3.     byte[] b;
  4.     string decrypted;
  5.     try
  6.     {
  7.         b = Convert.FromBase64String(encrString);
  8.         decrypted = System.Text.ASCIIEncoding.ASCII.GetString(b);
  9.     }
  10.     catch (FormatException fe)
  11.     {
  12.         decrypted = “”;
  13.     }
  14.     return decrypted;
  15. }
  16. public string EnryptString(string strEncrypted)
  17. {
  18.     byte[] b = System.Text.ASCIIEncoding.ASCII.GetBytes(strEncrypted);
  19.     string encrypted = Convert.ToBase64String(b);
  20.     return encrypted;
  21. }

Still The above code is not enough for me because I want to do something with my choice. Then I had implemented the code with specify charter to use in Encrypt method.

Leave a Reply

Your email address will not be published.

Skip to toolbar