This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ComputeMd5(string input, bool convert2smallLetters = false) | |
{ | |
MD5 md5 = MD5.Create(); | |
byte[] inputBytes = Encoding.ASCII.GetBytes(input); | |
byte[] hash = md5.ComputeHash(inputBytes); | |
StringBuilder sb = new StringBuilder(); | |
for (int i = 0; i < hash.Length; i++) | |
{ | |
if (!convert2smallLetters) | |
sb.Append(hash[i].ToString("X2")); | |
else | |
sb.Append(hash[i].ToString("x2")); | |
} | |
return sb.ToString(); | |
} |
No comments:
Post a Comment