public void VerifyHashAsUnique() { byte[] hash1 = SaltedHashProvider.CreateHash(this.plainText); byte[] hash2 = SaltedHashProvider.CreateHash(this.plainText); Assert.IsFalse(CryptographyUtility.CompareBytes(hash1, hash2)); }
public void CreateHashWithSalt() { byte[] saltedHash = SaltedHashProvider.CreateHash(this.plainText); int saltLength = 16; int hashMinusSaltLength = 20; byte[] salt = new byte[saltLength]; byte[] hashMinusSalt = new byte[hashMinusSaltLength]; Array.Copy(saltedHash, 0, salt, 0, saltLength); Array.Copy(saltedHash, saltLength, hashMinusSalt, 0, hashMinusSaltLength); byte[] saltedPlainText = new byte[this.plainText.Length + salt.Length]; salt.CopyTo(saltedPlainText, 0); this.plainText.CopyTo(saltedPlainText, saltLength); byte[] expectedResult = HashWithHMACSHA1(saltedPlainText); Assert.IsTrue(CryptographyUtility.CompareBytes(expectedResult, hashMinusSalt)); }