Decrypt Triple DES - CSharp System.Security.Cryptography

CSharp examples for System.Security.Cryptography:DES

Description

Decrypt Triple DES

Demo Code


using System.Security.Cryptography;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from w w w  . ja  v  a  2s .c o m

public class Main{

        public static string DecryptTripleDES(string base64Text)
        {
            TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider hashMD5 = new MD5CryptoServiceProvider();
            DES.Key = hashMD5.ComputeHash(Encoding.UTF8.GetBytes(strKey));
            DES.Mode = CipherMode.ECB;
            ICryptoTransform DESDecrypt = DES.CreateDecryptor();
            byte[] Buffer = Convert.FromBase64String(base64Text);
            return Encoding.UTF8.GetString(DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));
        }
}

Related Tutorials