C# Class Recognos.Core.PBKDF2SaltedHash

Secure password hash Uses PBKDF2 internally, as implemented by the Rfc2998DeriveBytes class. See http://en.wikipedia.org/wiki/PBKDF2 and http://msdn.microsoft.com/en-us/library/bwx8t0yt.aspx Code adappted from stackoverflow: http://code.google.com/p/stackid/source/browse/OpenIdProvider/Current.cs#1226
Afficher le fichier Open project: Recognos/Recognos.Core

Méthodes publiques

Méthode Description
GenerateHash ( string password ) : string

Generate a salted hash for a password. The returned string contains is formated like this: PBKDF2{nuber of iterations in hexa}.{salt length in hexa}.{salt}{key size in hexa}.{key}

IsPBKDF2Hash ( string hash ) : bool

Returns true if the hash starts with the PBKDF2 prefix

VerifyHash ( string password, string hash ) : bool

Verifies the hash.

Private Methods

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

Compute the actual hash for the password and salt using keySize as the key size in bytes.

GenerateSalt ( int size ) : byte[]

Generates the salt.

Method Details

GenerateHash() public static méthode

Generate a salted hash for a password. The returned string contains is formated like this: PBKDF2{nuber of iterations in hexa}.{salt length in hexa}.{salt}{key size in hexa}.{key}
public static GenerateHash ( string password ) : string
password string Passord to hash
Résultat string

IsPBKDF2Hash() public static méthode

Returns true if the hash starts with the PBKDF2 prefix
public static IsPBKDF2Hash ( string hash ) : bool
hash string hash to check for PBKDF2 prefix
Résultat bool

VerifyHash() public static méthode

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