Exemple #1
0
 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));
     }
 }