Ejemplo n.º 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);
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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)));
        }