Hashelés

using System.Security.Cryptography;

MD5 generálás
public static string GenerateMD5(string input)
{
    MD5 md5 = MD5.Create();
    byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(input));
    StringBuilder sBuilder = new StringBuilder();
    for (int i = 0; i < data.Length; i++)
    {
        sBuilder.Append(data[i].ToString("X2"));
    }
    return sBuilder.ToString();
}
 
SHA512 generálás
public static string GenerateSHA512(string input)
{
    SHA512 sha512 = SHA512Managed.Create();
    byte[] data = sha512.ComputeHash(Encoding.UTF8.GetBytes(input));
    StringBuilder sBuilder = new StringBuilder();
    for (int i = 0; i < data.Length; i++)
    {
        sBuilder.Append(data[i].ToString("X2"));
    }
    return sBuilder.ToString();
}
Mobilos kategóriák: