C# Class Recognos.Core.SaltedHash

Implementation for hashing a salted password and verifying the hash.
Afficher le fichier Open project: Recognos/Recognos.Core Class Usage Examples

Méthodes publiques

Méthode Description
Generate ( string password ) : string

Generates the hash.

SaltedHash ( ) : System.Linq

Initializes a new instance of the SaltedHash class.

Default constructor which initializes the SaltedHash with the SHA256Managed algorithm and a Salt of 4 bytes ( or 4*8 = 32 bits)

SaltedHash ( HashAlgorithm hashAlgorithm, int saltLength ) : System.Linq

Initializes a new instance of the SaltedHash class.

Verify ( string password, string hash ) : bool

Verifies the hash.

VerifyHash ( string password, string hash ) : bool

Verifies the hash.

Private Methods

Méthode Description
ComputeHash ( byte password, byte salt ) : byte[]

The actual hash calculation is shared by both GetHashAndSalt and the VerifyHash functions

GenerateHash ( string password ) : string
GenerateSalt ( ) : byte[]

Generates the salt.

Method Details

Generate() public static méthode

Generates the hash.
public static Generate ( string password ) : string
password string The password.
Résultat string

SaltedHash() public méthode

Initializes a new instance of the SaltedHash class.
Default constructor which initializes the SaltedHash with the SHA256Managed algorithm and a Salt of 4 bytes ( or 4*8 = 32 bits)
public SaltedHash ( ) : System.Linq
Résultat System.Linq

SaltedHash() public méthode

Initializes a new instance of the SaltedHash class.
public SaltedHash ( HashAlgorithm hashAlgorithm, int saltLength ) : System.Linq
hashAlgorithm System.Security.Cryptography.HashAlgorithm A HashAlgorihm which is derived from HashAlgorithm. C# provides /// the following classes: SHA1Managed,SHA256Managed, SHA384Managed, SHA512Managed and MD5CryptoServiceProvider
saltLength int Length of the salt.
Résultat System.Linq

Verify() public static méthode

Verifies the hash.
public static Verify ( string password, string hash ) : bool
password string The password.
hash string The hash.
Résultat bool

VerifyHash() public méthode

Verifies the hash.
public VerifyHash ( string password, string hash ) : bool
password string The password.
hash string The hash.
Résultat bool