C# Secure Hash String
--
Generates an SHA type hash of the passed in value and salt.
Hash is 88 characters always
The value for hasing
SALT for the hash
*/
public static string SHAHash(string valueToHash, string salt)
{
System.Security.Cryptography.SHA512Managed hasher = new System.Security.Cryptography.SHA512Managed();
Byte[] valueToHashAsByte = System.Text.Encoding.UTF8.GetBytes(string.Concat(valueToHash, salt));
Byte[] returnBytes = hasher.ComputeHash(valueToHashAsByte);
hasher.Clear();
return Convert.ToBase64String(returnBytes);
}
No comments:
Post a Comment