Ejemplo n.º 1
0
        public void TestValidatePassword()
        {
            using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
            {
                Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD + " "));
                Assert.IsFalse(pwd1.VerifyPassword(TEST_PASSWORD.Substring(0, TEST_PASSWORD.Length-1)));
                Assert.IsFalse(pwd1.VerifyPassword(""));

                Assert.IsTrue(pwd1.VerifyPassword(TEST_PASSWORD));
                Assert.IsTrue(pwd1.VerifyPassword(Password.Encoding.GetBytes(TEST_PASSWORD)));
                Assert.IsTrue(pwd1.VerifyPassword(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD))));
                Assert.IsTrue(pwd1.VerifyPassword(new Password(TEST_PASSWORD)));
            }
        }
Ejemplo n.º 2
0
        public void TestClearBytes()
        {
            byte[] password = new byte[16];
            new Random().NextBytes(password);

            using (PasswordHash pwd1 = new PasswordHash(false, password))
                Assert.IsTrue(pwd1.VerifyPassword(password));

            using (PasswordHash pwd1 = new PasswordHash(true, password))
                Assert.AreEqual(new byte[16], password);
        }