/// <summary> /// Compares plain text input with a computed hash using the configured <c>HashAlgorithm</c>. /// <seealso cref="IHashProvider.CompareHash"/> /// </summary> /// <param name="plaintext"><seealso cref="IHashProvider.CompareHash"/></param> /// <param name="hashedtext"><seealso cref="IHashProvider.CompareHash"/></param> /// <returns><seealso cref="IHashProvider.CompareHash"/></returns> public bool CompareHash(byte[] plaintext, byte[] hashedtext) { ArgumentValidation.CheckForNullReference(plaintext, "plainText"); ArgumentValidation.CheckForNullReference(hashedtext, "hashedText"); ArgumentValidation.CheckForZeroBytes(hashedtext, "hashedText"); bool result = false; byte[] hashedPlainText = null; byte[] salt = null; try { salt = ExtractSalt(hashedtext); hashedPlainText = CreateHashWithSalt(plaintext, salt); } finally { CryptographyUtility.ZeroOutBytes(salt); } result = CryptographyUtility.CompareBytes(hashedPlainText, hashedtext); SecurityCryptoHashCheckEvent.Fire(string.Empty); if (!result) { SecurityCryptoHashCheckFailureEvent.Fire(string.Empty); } return(result); }
private void FireSecurityCryptoHashFailureEvent() { SecurityCryptoHashCheckFailureEvent.Fire(testMessage); }
private void FireSecurityCryptoHashFailureEvent() { SecurityCryptoHashCheckFailureEvent.Fire("test"); }