Exemple #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
            });
        }
Exemple #2
0
        public static bool ValidatePassword(string passwordToValidate, UserPasswordHashed dbPassword)
        {
            var hashToCheck = CipherHelper.Encrypt(passwordToValidate, dbPassword.PasswordSalt);

            return(hashToCheck == dbPassword.HashedPassword);
        }