public static string Decrypt(string text) { var key3 = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }; var key2 = new byte[] { 0x02, 0x03, 0x15, 0x11, 0x13, 0x03, 0x04, 0x06 }; var key1 = new byte[] { 0x22, 0x11, 0x12, 0x13, 0x14, 0x9, 0x08, 0x07 }; var iv = new byte[] { 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8 }; var bytes = Encoding.Default.GetBytes(text); var data = Des.Decrypt(bytes, key1, iv); data = Des.Decrypt(data, key2, iv); data = Des.Decrypt(data, key3, iv); return(Encoding.Default.GetString(data)); }
private static void Main() { Console.WriteLine("Enter crypted text"); var str = Console.ReadLine(); Console.WriteLine("DES"); var crypted = Des.Crypt(str); Console.WriteLine("crypted = " + crypted); var decrypted = Des.Decrypt(crypted); Console.WriteLine("decrypted = " + decrypted); Console.WriteLine("Triple DES"); crypted = TripleDes.Crypt(str); Console.WriteLine("crypted = " + crypted); decrypted = TripleDes.Decrypt(crypted); Console.WriteLine("decrypted = " + decrypted); Console.ReadLine(); }