public HashService(HashConfig hashConfig) { _hashConfig = hashConfig ?? throw new ArgumentNullException(nameof(hashConfig)); if (string.IsNullOrEmpty(_hashConfig.salt)) { throw new KeyNotFoundException($"Salt not set in secret: sp.auth.authenticate.Salt"); } var saltAlg = _hashConfig.algorithm?.ToLower() ?? ""; switch (saltAlg) { case "sha256": _hashAlgorithm = SHA256.Create(); break; case "sha384": _hashAlgorithm = SHA384.Create(); break; case "sha512": _hashAlgorithm = SHA512.Create(); break; default: _hashAlgorithm = MD5.Create(); break; } }
public SecurityModel() { queryConfigurator = new SecurityMsSqlServerQueryConfigurator(); hashWorker = new HashWorker(); HashConfig hc = new HashConfig(); hc.numberOfHashing = 100000; hc.sultLength = 20; hashWorker.setConfig(hc); }
public void creatAdmin(string connectionString, string login, string password) { HashWorkerInterface <HashConfig> hashWorker = new HashWorker(); HashConfig hc = new HashConfig(); hc.numberOfHashing = 100000; hc.sultLength = 20; hashWorker.setConfig(hc); SecurityUserInterface user = new SecurityUser(login, password); user.setAdmin(true); string sult = hashWorker.getSult(user); dataBaseController.configAndExecute(connectionString, queryConfigurator.addAdmin(user.getLogin(), hashWorker.getHash(user.getPassword(), sult), sult)); }
public HttpContextService(IHttpContextAccessor httpContextAccessor, HashConfig hash) { _httpContextAccessor = httpContextAccessor; _hash = hash; }