private void RunEncryptionUsingTripleDES() { Console.WriteLine("Encryption Using Triple DES started"); Console.WriteLine(); CryptographyExample cryptographyExample = new CryptographyExample(8); // we are using 24 bytes to make use of the tripple key variants of triple DES // 24 bytes represents three 64 bit keys or three 8 byte keys // under the covers our data will be encrypted with key1, then with key2, then with key3 byte[] key = cryptographyExample.GenerateRandomNumber(24); // we could just send in 16 bytes and it will still work fine, however this means that // under the covers our data will get encrypted using the first key, then encrypted again using the 2nd key, then once more // using the first key again. //byte[] key = cryptographyExample.GenerateRandomNumber(16); byte[] initializationVector = cryptographyExample.GenerateRandomNumber(8); const string originalMessage = "Text To Encrypt"; Console.WriteLine(String.Format("Message before encryption: {0}", originalMessage)); byte[] encryptedMessage = cryptographyExample.EncryptUsingTripleDES(Encoding.UTF8.GetBytes(originalMessage), key, initializationVector); Console.WriteLine(String.Format("Message after encryption: {0}", Encoding.UTF8.GetString(encryptedMessage))); byte[] decryptedMessage = cryptographyExample.DecryptUsingTripleDES(encryptedMessage, key, initializationVector); Console.WriteLine(String.Format("Message after decryption: {0}", Encoding.UTF8.GetString(decryptedMessage))); Console.WriteLine(); Console.WriteLine("Encryption Using Triple DES ended"); }