Esempio n. 1
0
        public void Validate()
        {
            var salt = Passwords.GenerateSalt();

            Assert.IsTrue(Passwords.Validate(Passwords.Hash("123", salt), "123", salt));
            Assert.IsFalse(Passwords.Validate(Passwords.Hash("a", salt), "A", salt));
            Assert.IsTrue(Passwords.Validate(Passwords.Hash("", salt), null, salt));
        }
Esempio n. 2
0
        public void Hash()
        {
            const string password = "******";
            var          salt     = Passwords.GenerateSalt();
            var          hash     = Passwords.Hash(password, salt);

            Passwords.Hash(password, salt).AssertEqual(hash);
            Assert.AreNotEqual(password, hash);
            Assert.AreNotEqual(salt, hash);

            hash = Passwords.Hash("", salt);

            Assert.IsTrue(hash.Length > 0);
            Passwords.Hash(null, salt).AssertEqual(hash);
        }