LitDev.StringEncryption.CalculateMD5Hash C# (CSharp) Method

CalculateMD5Hash() public static method

public static CalculateMD5Hash ( string input ) : string
input string
return string
        public static string CalculateMD5Hash(string input)
        {
            try
            {
                MD5 md5 = MD5.Create();
                byte[] inputBytes = Encoding.UTF8.GetBytes(input);
                byte[] hash = md5.ComputeHash(inputBytes);
                return HexString(hash);
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
            return "";
        }

Usage Example

Example #1
0
 /// <summary>
 /// Create an MD5 hash of a text input (http://wikipedia.org/wiki/MD5).
 /// This 32 character hash is recommended where a general or shorter hash is required (password or data integrity).
 /// </summary>
 /// <param name="text">A text or password to create a hash.</param>
 /// <returns>The 32 character hex MD5 Hash.</returns>
 public static Primitive MD5Hash(Primitive text)
 {
     return(StringEncryption.CalculateMD5Hash(text));
 }