Beispiel #1
0
 public LoginSettings(string connectionString, string tableName, string usernameColumn, string passwordColumn, string saltColumn, HashingMethodType hashingMethod, int saltSize = 32)
 {
     HashingMethod    = hashingMethod;
     ConnectionString = connectionString;
     TableName        = tableName;
     UsernameColumn   = usernameColumn;
     PasswordColumn   = passwordColumn;
     SaltColumn       = saltColumn;
     SaltSize         = saltSize;
 }
        /// <summary>
        /// Checks if the Hashing method is supported.
        /// Throw exception if an unsupported method is chosen.
        /// Returns IHashingMethod if success.
        /// </summary>
        /// <param name="hashingMethod">HashingMethodType to check - returns the corresponding IHashingMethod.</param>
        /// <returns></returns>
        private IHashingMethod ViableHashingMethodCheck(HashingMethodType hashingMethod)
        {
            IHashingMethod method = null;

            switch (hashingMethod)
            {
            case HashingMethodType.SHA256:
                method = new HashingSHA256();
                break;

            default: throw new ArgumentException("Not a viable hashing method.", "hashingMethod");
            }

            return(method);
        }
 /// <summary>
 /// Settings Constructor includes hashingmethod, salt size, and number of iterations.
 /// </summary>
 /// <param name="hashingMethod">Hashing method to be used (SHA256)</param>
 /// <param name="saltSize">Size of salt used in hashing - default 32</param>
 /// <param name="numberOfIterations">Number of iterations used while hashing - default 50000</param>
 public HashingSettings(HashingMethodType hashingMethod, int saltSize = 32, int numberOfIterations = 50000)
 {
     HashingMethod      = hashingMethod;
     SaltSize           = saltSize;
     NumberOfIterations = numberOfIterations;
 }