Created
March 28, 2014 18:59
-
-
Save angelobelchior/9840401 to your computer and use it in GitHub Desktop.
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
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