예제 #1
0
        public static UserPasswordHashed GetHashedCredentials(string password)
        {
            var generator = new System.Security.Cryptography.RNGCryptoServiceProvider();
            var salt      = new byte[6];

            generator.GetBytes(salt);
            var saltString     = Encoding.Default.GetString(salt);
            var hashedPassword = CipherHelper.Encrypt(password, saltString);

            return(new UserPasswordHashed {
                HashedPassword = hashedPassword, PasswordSalt = saltString
            });
        }
예제 #2
0
        public static bool ValidatePassword(string passwordToValidate, UserPasswordHashed dbPassword)
        {
            var hashToCheck = CipherHelper.Encrypt(passwordToValidate, dbPassword.PasswordSalt);

            return(hashToCheck == dbPassword.HashedPassword);
        }