Triple DES Encryption


Keywords: Triple DES, Encryption, C#
Publish Date: 1/3/2013
Description: Easy Encryption using TripleDES

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):

Name: Allan Chadwick
Comment Date: 6/5/2013
Comment:
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!


Leave a Comment:




    Captcha Challenge