public static string key { get { return Key; } Set { key = value; } }
DES encryption
<summary>//DES Encrypt//</summary>/<param name= "encr Yptstring "> Strings to be encrypted </param>//<returns> encrypted strings </returns> public static string Desencry PT (String encryptstring) {byte[] keybytes = System.Text.Encoding.UTF8.GetBytes (key. Substring (0, 8)); byte[] Keyiv = keybytes; byte[] Inputbytearray = Encoding.UTF8.GetBytes (encryptstring); System.Security.Cryptography.DESCryptoServiceProvider Provider = new System.Security.Cryptography.DESCryptoServiceProvider (); System.IO.MemoryStream mstream = new System.IO.MemoryStream (); System.Security.Cryptography.CryptoStream Cstream = new System.Security.Cryptography.CryptoStream (Mstream, provider . CreateEncryptor (Keybytes, Keyiv), System.Security.Cryptography.CryptoStreamMode.Write); Cstream.write (Inputbytearray, 0, inputbytearray.length); Cstream.flushfinalbloCK (); Return convert.tobase64string (Mstream.toarray ()); }
Des decryption
<summary>//Function:des Decrypt//</summary>/<param NA Me= "Decryptstring" > String to Decrypt </param>//<returns> decrypted string </returns> public static string Desdecrypt (String decryptstring) {byte[] keybytes = Encoding.UTF8.GetBytes (key. Substring (0, 8)); byte[] Keyiv = keybytes; byte[] Inputbytearray = convert.frombase64string (decryptstring); System.Security.Cryptography.DESCryptoServiceProvider Provider = new System.Security.Cryptography.DESCryptoServiceProvider (); System.IO.MemoryStream mstream = new System.IO.MemoryStream (); System.Security.Cryptography.CryptoStream Cstream = new System.Security.Cryptography.CryptoStream (Mstream, provider . CreateDecryptor (Keybytes, Keyiv), System.Security.Cryptography.CryptoStreamMode.Write); Cstream.write (Inputbytearray, 0, inputbytearray.length); Cstream.flushfinalblock(); Return Encoding.UTF8.GetString (Mstream.toarray ()); }
C#des Plus decryption