Created
May 14, 2014 01:17
-
-
Save pisceanfoot/67970cb42b697d0fc18d to your computer and use it in GitHub Desktop.
EnCryptographyHelper with md5
This file contains hidden or 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 class EnCryptographyHelper | |
{ | |
public static string MD5Encoding(byte[] content) | |
{ | |
MD5 md5 = MD5.Create(); | |
byte[] bytes = md5.ComputeHash(content); | |
return HexToString(bytes); | |
} | |
public static string MD5Encoding(string content, Encoding encoding) | |
{ | |
MD5 md5 = MD5.Create(); | |
byte[] bytes = md5.ComputeHash(encoding.GetBytes(content)); | |
return HexToString(bytes); | |
} | |
public static string HexToString(byte[] buffer) | |
{ | |
StringBuilder result = new StringBuilder(); | |
for (int i = 0; i < buffer.Length; i++) | |
{ | |
result.Append(buffer[i].ToString("X2")); | |
} | |
return result.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment