public static string MD5String(this string value)
{
MD5 md5Hasher =MD5.Create();
byte[] data= md5Hasher.ComputeHash(Encoding.Default.GetBytes(value));
StringBuilder sBuilder = new StringBuilder();
for(int i=0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
return sBuilder.ToString();
}
public static bool VerifyMD5String(this string value)
{
string hashOfInput = MD5String(value);
StringComparer comparer = StringComparer.OrdinalIgnoreCase;
return 0== comparer.Compare(hashOfInput,hash) ? true : false;
}
Hiç yorum yok:
Yorum Gönder