How to get a string in MD5 in C#.Net

Posted by Ruben Canton on February 17, 2012 at 9:22 am
categories Web programming, Web security

Here it is:

        public static String getInMD5(String inputString) {
            byte[] input = Encoding.UTF8.GetBytes(inputString);
            byte[] output = MD5.Create().ComputeHash(input);
            StringBuilder sb = new StringBuilder(output.Length);
            for (int i = 0; i < output.Length; i++) {
                sb.Append(output[i].ToString("X2"));
            }
            return sb.ToString();
        }

You may need this too:

using System.Text;
using System.Security.Cryptography;

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

WordPress Themes