blog tag

Triple DES Encryption

Description: Easy Encryption using TripleDES
Publish Date: 01/03/2013
Keywords: Triple DES Encryption C#

I took much of this from an example I found online years ago but I can't find the link just now. Here is some msdn info...

http://msdn.microsoft.com/en-us/library/system.security.cryptography.tripledescryptoserviceprovider.aspx

This allows you to store the  key and vector as a string where you see fit, like web.config, sql, or a text file in a secret location.

Warning about Triple DES: It appears that AES is the current go to encryption standard, so keep that in mind before using 3DES :).


        [TestMethod]
        public void TripleDESKeyVector()
        {
            var key = MyTripleDES.CreateNewKey();
            var vector = MyTripleDES.CreateNewVector();

            var tripleDes = new MyTripleDES(key: key, iv: vector);

            var myString = "Yo ho ho, triple des to go.";

            var encryptedVal = tripleDes.Encrypt(myString);

            var decryptedVal = tripleDes.Decrypt(encryptedVal);
        }
Comments: 1
Allan Chadwick (06/05/2013)

I updated the encrypt and decrypt with return HttpServerUtility.UrlTokenEncode(output) because I needed the encrypted value in a url and in browser DOM. Check out the Captha url!


© Chadwick 2021