public void MD5Test(string input) { using (HashProvider oneWayCrypto = HashProvider.MD5) { string result = oneWayCrypto.GenerateString(input); string result2 = oneWayCrypto.GenerateString(input); Assert.IsNotNull(result); Assert.AreEqual(32, result.Length); Assert.AreEqual(-1, result.IndexOf('-')); Assert.AreEqual(result, result2); Util.WL(result); } }
public void MD5SaltEncryptAndCompare(string password, string salt) { using (HashProvider oneWayCrypto = HashProvider.MD5) { string encrypted = oneWayCrypto.GenerateString(password, salt); Assert.IsTrue(oneWayCrypto.Compare(password, encrypted, salt.Length)); Assert.IsFalse(oneWayCrypto.Compare(password, encrypted, salt.Length - 1)); Assert.IsFalse(oneWayCrypto.Compare(password, encrypted, salt.Length + 1)); Assert.IsFalse(oneWayCrypto.Compare(password + "x", encrypted, salt.Length)); } }