Created
September 23, 2012 21:37
-
-
Save jaysonrowe/3773128 to your computer and use it in GitHub Desktop.
Class to generate MD5 hash of string
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Security.Cryptography; | |
namespace MD5Util | |
{ | |
public class Encryptor | |
{ | |
public string MD5Hash(string text) | |
{ | |
MD5 md5 = new MD5CryptoServiceProvider(); | |
md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(text)); | |
byte[] result = md5.Hash; | |
StringBuilder strBuilder = new StringBuilder(); | |
for (int i = 0; i < result.Length; i++) | |
{ | |
strBuilder.Append(result[i].ToString("x2")); | |
} | |
return strBuilder.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment