SHARE
TWEET

Encryption procedures

gunnercrakr Nov 23rd, 2019 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected byte[] EncryptKey = ASCIIEncoding.ASCII.GetBytes("ask_us_for_key");
  2. public string DESEncrypt(string inString)
  3. {
  4.     MemoryStream ms = new MemoryStream();
  5.     CryptoStream cs = new CryptoStream(ms, new DESCryptoServiceProvider().CreateEncryptor(EncryptKey, EncryptKey), CryptoStreamMode.Write);
  6.     StreamWriter sw = new StreamWriter(cs);
  7.     sw.Write(inString);
  8.     sw.Flush();
  9.     cs.FlushFinalBlock();
  10.     sw.Flush();
  11.     return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
  12. }
  13. public string DESDecrypt(string inString)
  14. {
  15.     try
  16.     {
  17.         return new StreamReader(new CryptoStream(new MemoryStream( Convert.FromBase64String(inString)), new DESCryptoServiceProvider().CreateDecryptor(EncryptKey, EncryptKey), CryptoStreamMode.Read)).ReadToEnd();
  18.     }
  19.     catch
  20.     {
  21.     }
  22.     return "";
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top