Example #1
0
        public static bool VerifyPass(string password, string passSalt, string passHash)
        {
            string attemptHash;

            using (var hmac = new HMACSHA512())
            {
                var df = new Pbkdf2(hmac, Encoding.ASCII.GetBytes(password), Convert.FromBase64String(passSalt), 30000);
                attemptHash = Convert.ToBase64String(df.GetBytes(64));
            }
            return(attemptHash == passHash);
        }
Example #2
0
        public static string[] CreatePassHash(string password)
        {
            string[] saltHash = new string[2];

            byte[] salt = new byte[SaltByteLength];
            RNGCryptoServiceProvider csprng = new RNGCryptoServiceProvider();

            csprng.GetBytes(salt);
            saltHash[0] = Convert.ToBase64String(salt);

            using (var hmac = new HMACSHA512())
            {
                var df = new Pbkdf2(hmac, Encoding.ASCII.GetBytes(password), salt, 30000);
                saltHash[1] = Convert.ToBase64String(df.GetBytes(64));
            }

            return(saltHash);
        }