Posts

Showing posts from 2011

Password Encryption to MD5

This code describes that how to encrypt the provided password in C#.net windows form or in asp.net. I have used mysql database server for my C#.net application where password is encrypted. So, when I am logging in my application, need to encrypt the given password and i have wrote the following code in my application. First I have declare  Byte type variables for original password and encrypted password. Then I have created an object for MD5 encryption. So, lets enjoy. public static string EncodePassword(string originalPassword) { //Declarations Byte[] originalBytes; Byte[] encodedBytes; MD5 md5; //Instantiate MD5CryptoServiceProvider, get bytes for original  //password and  compute hash (encoded password) md5 = new MD5CryptoServiceProvider(); originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword); encodedBytes = md5.ComputeHash(originalBytes); //Convert encoded bytes back to a 'reada...