/// <summary> /// Verifies the hash of the <paramref name="plainTextPassword" /> matches the specified <paramref name="passwordHash" />. /// </summary> /// <param name="plainTextPassword">The password to verify.</param> /// <param name="passwordHash">The password hash.</param> /// <returns>Whether or not the password is the same.</returns> /// <exception cref="System.ArgumentNullException"> /// plainTextPassword /// or /// passwordHash /// </exception> public bool VerifyHash(string plainTextPassword, string passwordHash) { if (string.IsNullOrWhiteSpace(plainTextPassword)) { throw new ArgumentNullException("plainTextPassword"); } if (string.IsNullOrWhiteSpace(passwordHash)) { throw new ArgumentNullException("passwordHash"); } var passwordHashBytes = passwordHash.ToBytesFromHexadecimal(); var saltBytes = CryptographyUtility.GetBytes(passwordHashBytes, SaltLength); var saltedPlainTextHashBytes = CreateHashBytes(new UTF8Encoding(false).GetBytes(plainTextPassword), saltBytes); return(CryptographyUtility.CompareBytes(passwordHashBytes, saltedPlainTextHashBytes)); }