public static bool ValidatePassword(string password, CryptoHashContainer hashContainer) { byte[] salt = Convert.FromBase64String(hashContainer.salt); byte[] hash = Convert.FromBase64String(hashContainer.hash); byte[] testHash = PBKDF2(password, salt, PBKDF2_ITERATIONS, hash.Length); return SlowEquals(hash, testHash); }
public static bool ValidatePassword(string password, CryptoHashContainer hashContainer) { byte[] salt = Convert.FromBase64String(hashContainer.salt); byte[] hash = Convert.FromBase64String(hashContainer.hash); byte[] testHash = PBKDF2(password, salt, PBKDF2_ITERATIONS, hash.Length); return(SlowEquals(hash, testHash)); }
public static CryptoHashContainer CreateHash(string password) { // Generate a random salt RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider(); byte[] salt = new byte[SALT_BYTES]; csprng.GetBytes(salt); //Hash password byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES); CryptoHashContainer cc = new CryptoHashContainer(); return new CryptoHashContainer(Convert.ToBase64String(salt), Convert.ToBase64String(hash)); }
public static CryptoHashContainer CreateHash(string password) { // Generate a random salt RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider(); byte[] salt = new byte[SALT_BYTES]; csprng.GetBytes(salt); //Hash password byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES); CryptoHashContainer cc = new CryptoHashContainer(); return(new CryptoHashContainer(Convert.ToBase64String(salt), Convert.ToBase64String(hash))); }