Esempio n. 1
0
        public void TestBCryptConstructorReturnValueWithHMACSHA256()
        {
            string password = "******";
            BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA256);
            BCrypt      bCrypt      = new BCrypt(configuration);
            BCryptValue bCryptValue = bCrypt.Hash(password);

            Assert.IsTrue(bCrypt.Valid(password, bCryptValue));
        }
Esempio n. 2
0
        public void TestBCryptConstructorReturnValue()
        {
            string password = "******";
            BCryptConfiguration configuration = new BCryptConfiguration();
            BCrypt      bCrypt      = new BCrypt(configuration);
            BCryptValue bCryptValue = bCrypt.Hash(password);

            Assert.IsTrue(bCrypt.Valid(password, bCryptValue));
        }
Esempio n. 3
0
        public void TestBCryptConstructorReturnValueWithHMACSHA512AndInterationCountDescribeValue()
        {
            string password = "******";
            BCryptConfiguration configuration = new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2000);
            BCrypt      bCrypt      = new BCrypt(configuration);
            BCryptValue bCryptValue = bCrypt.Hash(password);

            Assert.IsTrue(bCrypt.Valid(password, bCryptValue.Salt, bCryptValue.Hashed));
        }
Esempio n. 4
0
        public void TestBCryptConstructorReturnValueWithHMACSHA512AndInterationCountDescribeValueSaltAndHashedLength()
        {
            const int           length        = 75;
            string              password      = "******";
            BCryptConfiguration configuration =
                new BCryptConfiguration(KeyDerivationPrf.HMACSHA512, 2000, length, length);
            BCrypt      bCrypt      = new BCrypt(configuration);
            BCryptValue bCryptValue = bCrypt.Hash(password);

            Assert.IsTrue(bCrypt.Valid(password, bCryptValue.Salt, bCryptValue.Hashed));
            Assert.AreEqual(2000, configuration.IterationCount);
            Assert.AreEqual(length, configuration.SaltBytesLength);
            Assert.AreEqual(length, configuration.NumBytesRequestedLength);
            Assert.AreEqual(bCryptValue.Salt.Length, 100);
            Assert.AreEqual(bCryptValue.Hashed.Length, 100);
        }
Esempio n. 5
0
 private void CreateUser()
 {
     if (!DataService.User.AsNoTrackingWithIdentityResolution().Any())
     {
         BCryptValue hash = Crypt.Hash("123456@@");
         User        user = new User
         {
             Email     = "*****@*****.**",
             Name      = "Fúlvio Cezar Canducci Dias",
             CreatedAt = System.DateTime.Now,
             Active    = true,
             Password  = hash.Hashed,
             Salt      = hash.Salt
         };
         DataService.User.Add(user);
         DataService.SaveChanges();
         DataService.Entry(user).State = EntityState.Detached;
     }
 }