Geeks With Blogs
Gaurav Taneja Great dreams... never even get out of the box. It takes an uncommon amount of guts to put your dreams on the line, to hold them up and say, "How good or how bad am I?" That's where courage comes in.
Encrypts th string to a byte array using the MD5 Encryption Algorithm

  public static string MD5Encryption(string strToEncrypt)
        {
            string strEnctypted = string.Empty;
            // Create instance of the crypto provider.
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            // Create a Byte array to store the encryption to return.
            byte[] hashedbytes;
            // Required UTF8 Encoding used to encode the input value to a usable state.
            UTF8Encoding textencoder = new UTF8Encoding();

            // let the show begin.
            hashedbytes = md5.ComputeHash(textencoder.GetBytes(strToEncrypt));

            // Destroy objects that aren't needed.
            md5.Clear();
            md5 = null;

            // return the hased bytes to the calling method.
            System.Text.Encoding enc = System.Text.Encoding.ASCII;
            strEnctypted = enc.GetString(hashedbytes);
            return strEnctypted;
        } Posted on Sunday, April 6, 2008 10:27 PM .Net | Back to top


Comments on this post: Encrypts the string to a byte array using the MD5 Encryption Algorithm + C#

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Gaurav Taneja | Powered by: GeeksWithBlogs.net