コード例 #1
0
        public async Task <ActionResult> Login([FromBody] User user)
        {
            string hashed = new HashingService().SHA1UTF8Hash(user.password);
            string suffix = hashed.Substring(5);

            HaveIBeenPwnedService service = new HaveIBeenPwnedService(config);
            string breachedHashes         = await service.GetBreachedHashes(hashed);

            Regex reg = new Regex($@"{suffix}:([0-9]*)", RegexOptions.Singleline);

            bool existing   = reg.IsMatch(breachedHashes);
            int  occurances = Int32.Parse(reg.Matches(breachedHashes)[0].Groups[1].Value);

            return(Ok(new { breachedPassword = existing, numberOfBreaches = occurances }));
        }