Last active
December 29, 2017 09:49
-
-
Save lamngockhuong/fd9631852dbc4af3ae48 to your computer and use it in GitHub Desktop.
[MD5 Hash Method In C# (using for password)] #csharp
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 MD5Hash(String source) | |
{ | |
MD5 md5 = new MD5CryptoServiceProvider(); | |
// compute hash from the bytes of text | |
md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(source)); | |
// get hash result after compute it | |
byte[] result = md5.Hash; | |
StringBuilder text = new StringBuilder(); | |
for (int i = 0; i < result.Length; i++) | |
{ | |
// change it into 2 hexadecimal digits | |
// for each byte | |
text.Append(result[i].ToString("x2")); | |
} | |
return text.ToString(); | |
} | |
------------------------- | |
Lam Ngoc Khuong | |
http://ngockhuong.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment