internal static bool IsHashMatchWithTolerantHashAlgorithm(this CryptoSettings cryptoProvider, byte[] data, byte[] expectedHash, HashAlgorithm? hashAlgorithm)
{
Requires.NotNull(cryptoProvider, "cryptoProvider");
Requires.NotNull(data, "data");
Requires.NotNull(expectedHash, "expectedHash");
if (!hashAlgorithm.HasValue)
{
hashAlgorithm = Utilities.GuessHashAlgorithmFromLength(expectedHash.Length);
}
var hasher = WinRTCrypto.HashAlgorithmProvider.OpenAlgorithm(hashAlgorithm.Value);
byte[] actualHash = hasher.HashData(data);
return Utilities.AreEquivalent(expectedHash, actualHash);
}