Example #1
0
 /// <summary>
 /// Checks the database if the entered user has the entered password.
 /// </summary>
 /// <param name="userName">User name to match with password.</param>
 /// <param name="pass">Password to match with username.</param>
 /// <returns>The UserInfo instance of the confirmed user or NULL for mismatch.</returns>
 public UserInfo ConfirmPassword(string userName, string inputedPass, HashWithSalt hashWithSalt)
 {
     if (Hash(inputedPass, hashWithSalt.Salt) == hashWithSalt.Hash)
     {
         return(new UserInfo("Admin", Enums.Privilege.Admin));
     }
     return(null);
 }
Example #2
0
        /// <summary>
        /// Accepts a string with user inputed password and returns a randomly generated salt
        /// hashsum of the combination.
        /// </summary>
        /// <param name="pass">User inputed password</param>
        /// <returns></returns>
        public HashWithSalt HashAndSaltPass(string pass)
        {
            var toReturn = new HashWithSalt();

            toReturn.Salt = GenerateSalt();
            toReturn.Hash = Hash(pass, toReturn.Salt);
            return(toReturn);
        }