Skip to content

Instantly share code, notes, and snippets.

@angelobelchior
Created March 28, 2014 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelobelchior/9840401 to your computer and use it in GitHub Desktop.
Save angelobelchior/9840401 to your computer and use it in GitHub Desktop.
using System;
using System.Text;
namespace Cryptography
{
public class MD5
{
public static string Encrypt(string text)
{
Throw.IfIsNullOrEmpty(text);
var md5Hasher = System.Security.Cryptography.MD5.Create();
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(text));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
sBuilder.Append(data[i].ToString("x2"));
return sBuilder.ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment