Hash functions are a common way to protect secure sensitive data such as passwords and digital signatures, Some of the modern commonly-used hash functions are RIPEMD160, MD5, SHA1, SHA256, SHA512 and SHA384.
public static string Sha256Hash(string rawData)
{
// Create a SHA256
using (SHA256 sha256Hash = SHA256.Create())
{
// ComputeHash - returns byte array
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
// Convert byte array to a string
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
2020-02-05