HashHelper Class


Helper methods for calculating and verifying hash values.

public static class HashHelper
System.Object → HashHelper


GenerateNumericCode(int) Generates a cryptographically strong sequence of random digits.
GenerateSalt(int) Generates a cryptographically strong sequence of random byte values.
GenerateToken(DateTime) Generates a base64url encoded validation token that expires at the specified time.
GetTokenExpiryDate(string) Gets the expiration time (UTC) for the specified token.
HashPassword(string, int?) Generates a PBKDF2 hash for the given plain text password and returns a base64 encoded result.
IsPasswordHash(string) Check if the supplied string looks like a hashed password.
IsTokenValid(string) Verifies that the supplied token has not expired.
MD5(Byte[]) Calculates an MD5 hash.
MD5(string) Calculates an MD5 hash.
SHA1(Byte[]) Calculates a SHA1 hash.
SHA1(string) Calculates a SHA1 hash.
SHA256(Byte[]) Calculates a SHA256 hash.
SHA256(string) Calculates a SHA256 hash.
VerifyPassword(string, string) Compares a hash of the specified plain text password to a given hash value. Plain text is hashed with the same salt value as the original hash.