Chủ Nhật, 8 tháng 1, 2017

Hash Algorithm examples in .Net

public static byte[] ComputeHashSha1(byte[] toBeHashed)
{
    using (var sha1 = SHA1.Create())
    {
        return sha1.ComputeHash(toBeHashed);
    }
}
 
public static byte[] ComputeHashSha256(byte[] toBeHashed)
{
    using (var sha256 = SHA256.Create())
    {
        return sha256.ComputeHash(toBeHashed);
    }
}
 
public static byte[] ComputeHashSha512(byte[] toBeHashed)
{
    using (var sha512 = SHA512.Create())
    {
        return sha512.ComputeHash(toBeHashed);
    }
}
 
public static byte[] ComputeHashMd5(byte[] toBeHashed)
{
    using (var md5 = MD5.Create())
    {
        return md5.ComputeHash(toBeHashed);
    }
}

Không có nhận xét nào :

Đăng nhận xét