public void ScryptTest()
        {
            var options = PasswordHash.CreateOptions(1 << 8, 3);

            string password = "******";
            var    hash     = PasswordHash.Hash(password, PasswordHash.Scrypt, options);

            Assert.IsTrue(PasswordHash.Verify(hash, password));
            Assert.IsFalse(PasswordHash.Verify(hash, "the wrong password"));
        }
        public void NeedsRehashTest()
        {
            var options = PasswordHash.CreateOptions(1 << 8, 3);

            string password = "******";
            var    hash     = PasswordHash.Hash(password, PasswordHash.Argon2id, options);

            Assert.IsFalse(PasswordHash.NeedsRehash(hash, options));

            var newOptions = PasswordHash.CreateOptions(1 << 8, 4);

            Assert.IsTrue(PasswordHash.NeedsRehash(hash, newOptions));
        }
Beispiel #3
0
        public void ScryptTest()
        {
            string password = "******";
            var    options  = PasswordHash.CreateOptions(1 << 8, 3);

            var result = Sodium.KDF.Scrypt(password, options);

            Assert.AreEqual(32, result.Length);

            var salt = Sodium.Core.GetRandomBytes(32);

            result = Sodium.KDF.Scrypt(password, salt, options);
            Assert.AreEqual(32, result.Length);
        }