Implementing Cryptography by using MD5 algorithm.

In last blog I had explained that how to implement cryptography by using SHA1 algorithm. In this article I will describe another method to implement concept of Cryptography in C#. Here I will use MD5 algorithm to encrypt data from user.

Following code demonstrate use of MD5 algorithm
public static void encryptMd5() 
{
            string strText = '';
            Console.Write('Enter Name of Text--->   ');
            strText = Console.ReadLine();
            MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
            byte[] encryptData = provider.ComputeHash(Encoding.Default.GetBytes(strText));
            Console.WriteLine('Encrypted Value Is....');
            foreach (byte tempData in encryptData)
            {
                Console.Write(tempData.ToString('x'));
            }
            Console.WriteLine();
}

Output of the above code snippet is as follows

Enter Name of Text--->   MindStick
Encrypted Value Is....
dcfff63dc26387bf19cea60d5de240

Enter Name of Text--->   Washington
Encrypted Value Is....
6d69689d056a27bce65398abc70297a

Last updated:9/18/2014 1:23:54 PM
Anonymous User

Anonymous User

I am a content writter !

3 Comments

Anurag Chaurasia
Anurag Chaurasia

Hello Sir,
        I need the Programme on the decryption too...
                                                                        

Anonymous User
Anonymous User

You cannot decrypt hashed sha1 value. You can only compare one hash value to another hash value.

Shrikant Mishra
Shrikant Mishra

Sir, your article is undoubtedly of a high quality. With its help, we got more information about implementing cryptography by using MD5 algorithm.

https://www.mindstick.com/blog/119/implementing-cryptography-in-c-sharp-dot-net-by-using-sha1-algorithm

Leave Comment