/// <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>
        /// Used to setup login functionality.
        /// Takes LoginSettings as argument.
        /// </summary>
        /// <param name="settings">Settings used to setup login.</param>
        public HashingService(HashingSettings settings)
        {
            this._settings = settings;

            IHashingMethod method;

            switch (settings.HashingMethod)
            {
            case HashingMethodType.SHA256:
                method = new HashingSHA256(settings.NumberOfIterations);
                break;

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

            this._hashingMethod = method;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Used to setup login functionality.
 /// Takes LoginSettings as argument.
 /// </summary>
 /// <param name="settings">Settings used to setup login.</param>
 public LoginHandler(LoginSettings settings)
 {
     this._settings      = settings;
     this._hashingMethod = this.ViableHashingMethodCheck(this._settings.HashingMethod);
 }