C# Class Ru.GameSchool.Utilities.PasswordUtilities

A class handles hashing and salting passwords, and verifies them.
Afficher le fichier Open project: davidein/Ru.GameSchool

Méthodes publiques

Méthode Description
ComputeHash ( string plainText, string hashAlgorithm = null, byte saltBytes = null ) : string

Hashes a password and returns a string value.

VerifyHash ( string plainText, string hashValue, string hashAlgorithm = null ) : bool

Compares a hash of the specified plain text value to a given hash value. Plain text is hashed with the same salt value as the original hash.

Method Details

ComputeHash() public static méthode

Hashes a password and returns a string value.
public static ComputeHash ( string plainText, string hashAlgorithm = null, byte saltBytes = null ) : string
plainText string The password to hash.
hashAlgorithm string The algorithm to be used, if null MD5 will be used.
saltBytes byte Salt bytes. This parameter can be null, in which case a random salt value will be generated.
Résultat string

VerifyHash() public static méthode

Compares a hash of the specified plain text value to a given hash value. Plain text is hashed with the same salt value as the original hash.
public static VerifyHash ( string plainText, string hashValue, string hashAlgorithm = null ) : bool
plainText string Plain text to be verified against the specified hash. The function does not check whether this parameter is null.
hashValue string Base64-encoded hash value produced by ComputeHash function. This value includes the original salt appended to it.
hashAlgorithm string Name of the hash algorithm. Allowed values are: "MD5", "SHA1", "SHA256", "SHA384", and "SHA512" (if any other value is specified, MD5 hashing algorithm will be used). This value is case-insensitive.
Résultat bool