Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected byte[] EncryptKey = ASCIIEncoding.ASCII.GetBytes("ask_us_for_key");
- public string DESEncrypt(string inString)
- {
- MemoryStream ms = new MemoryStream();
- CryptoStream cs = new CryptoStream(ms, new DESCryptoServiceProvider().CreateEncryptor(EncryptKey, EncryptKey), CryptoStreamMode.Write);
- StreamWriter sw = new StreamWriter(cs);
- sw.Write(inString);
- sw.Flush();
- cs.FlushFinalBlock();
- sw.Flush();
- return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
- }
- public string DESDecrypt(string inString)
- {
- try
- {
- return new StreamReader(new CryptoStream(new MemoryStream( Convert.FromBase64String(inString)), new DESCryptoServiceProvider().CreateDecryptor(EncryptKey, EncryptKey), CryptoStreamMode.Read)).ReadToEnd();
- }
- catch
- {
- }
- return "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement