Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MyStore.Services: MD5Security.cs
using System.Text;
using System.Linq;
using System.Security.Cryptography;
namespace MyStore.Services
{
public static class MD5Security
{
public static string ToMD5Hash(this string str)
{
if (string.IsNullOrEmpty(str))
return null;
return Encoding.ASCII.GetBytes(str).ToMD5Hash();
}
public static string ToMD5Hash(this byte[] bytes)
{
if (bytes == null || bytes.Length == 0)
return null;
using (var md5 = MD5.Create())
{
return string.Join("", md5.ComputeHash(bytes).Select(x => x.ToString("X2")));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.