CSharp examples for System.Security.Cryptography:DES
DES Decrypt String with string key
using System.Text; using System.Security.Cryptography; using System.Linq; using System.IO;/*ww w . j a va2 s . c o m*/ using System.Collections.Generic; using System; public class Main{ public static string Decrypt(string decryptString, string decryptKey) { try { var rgbKey = Encoding.UTF8.GetBytes(decryptKey); var rgbIv = CryptKeys.DesKeys; var inputByteArray = Convert.FromBase64String(decryptString); var dcsp = new DESCryptoServiceProvider(); var mStream = new MemoryStream(); var cStream = new CryptoStream(mStream, dcsp.CreateDecryptor(rgbKey, rgbIv), CryptoStreamMode.Write); cStream.Write(inputByteArray, 0, inputByteArray.Length); cStream.FlushFinalBlock(); return Encoding.UTF8.GetString(mStream.ToArray()); } catch { return decryptString; } } }