28 lines
772 B
C#
28 lines
772 B
C#
//using XLua;
|
|
using System;
|
|
using System.Text;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace BF
|
|
{
|
|
public class NetMd5Encrypt
|
|
{
|
|
static public string Encrypt(string value)
|
|
{
|
|
using (MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider())
|
|
{
|
|
var md5Hash = md5.ComputeHash(Encoding.UTF8.GetBytes(value));
|
|
var md5Str = BitConverter.ToString(md5Hash).Replace("-", "");
|
|
return md5Str;
|
|
}
|
|
}
|
|
|
|
static public bool VerifyMd5Hash(string input, string hash)
|
|
{
|
|
var hashOfInput = Encrypt(input);
|
|
var comparer = StringComparer.OrdinalIgnoreCase;
|
|
return 0 == comparer.Compare(hashOfInput, hash);
|
|
}
|
|
}
|
|
}
|