public void Validate_WhenGivenAutoGeneratedString_ReturnsValid(int saltByteSize, int hashByteSize, int iterations, char[] delimiter) { var p = new PBKDF2CryptoProvider(saltByteSize, hashByteSize, iterations, delimiter); var csprng = new RNGCryptoServiceProvider(); var arr = new byte[128]; csprng.GetBytes(arr); var text = Encoding.UTF8.GetString(arr); Console.WriteLine("Text: {0}", text); var hash = p.CreateHash(text); Console.WriteLine("Hash: {0}", hash); var valid = p.ValidateHash(text, hash); Assert.IsTrue(valid); }
public void Validate_WhenGivenIncorrectTextAndHashCombination_ReturnsFalse(int saltByteSize, int hashByteSize, int iterations, char[] delimiter, string text, string correctHash) { var p = new PBKDF2CryptoProvider(saltByteSize, hashByteSize, iterations, delimiter); var valid = p.ValidateHash(text, correctHash); Assert.IsFalse(valid); }