Example #1
0
 public static bool ValidatePassword(string password, CryptoHashContainer hashContainer)
 {
     byte[] salt = Convert.FromBase64String(hashContainer.salt);
     byte[] hash = Convert.FromBase64String(hashContainer.hash);
     byte[] testHash = PBKDF2(password, salt, PBKDF2_ITERATIONS, hash.Length);
     return SlowEquals(hash, testHash);
 }
Example #2
0
 public static bool ValidatePassword(string password, CryptoHashContainer hashContainer)
 {
     byte[] salt     = Convert.FromBase64String(hashContainer.salt);
     byte[] hash     = Convert.FromBase64String(hashContainer.hash);
     byte[] testHash = PBKDF2(password, salt, PBKDF2_ITERATIONS, hash.Length);
     return(SlowEquals(hash, testHash));
 }
Example #3
0
        public static CryptoHashContainer CreateHash(string password)
        {
            // Generate a random salt
            RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();
            byte[] salt = new byte[SALT_BYTES];
            csprng.GetBytes(salt);

            //Hash password
            byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES);

            CryptoHashContainer cc = new CryptoHashContainer();
            return new CryptoHashContainer(Convert.ToBase64String(salt), Convert.ToBase64String(hash));
        }
Example #4
0
        public static CryptoHashContainer CreateHash(string password)
        {
            // Generate a random salt
            RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();

            byte[] salt = new byte[SALT_BYTES];
            csprng.GetBytes(salt);

            //Hash password
            byte[] hash = PBKDF2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES);

            CryptoHashContainer cc = new CryptoHashContainer();

            return(new CryptoHashContainer(Convert.ToBase64String(salt), Convert.ToBase64String(hash)));
        }