Ejemplo n.º 1
0
        /// <inheritdoc />
        public Task <bool> HasPasswordBeenPwned(string password)
        {
            var sha1Password = SHA1Util.SHA1HashStringForUTF8String(password);

            foreach (var file in _files)
            {
                var isPwned = IsInFile(sha1Password, file);
                if (isPwned)
                {
                    //stop as soon as we find it!
                    return(Task.FromResult(true));
                }
            }

            // checked all files, must be ok!
            return(Task.FromResult(false));
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task <bool> HasPasswordBeenPwned(string password)
        {
            var sha1Password = SHA1Util.SHA1HashStringForUTF8String(password);

            var formContent = new FormUrlEncodedContent(
                new Dictionary <string, string> {
                { "Password", sha1Password }
            });

            var msg = new HttpRequestMessage(HttpMethod.Post, _options.ApiUrl)
            {
                Content = formContent,
            };

            var response = await ThrottleRequest(() => _client.SendAsync(msg));

            return(HandleResponse(response));
        }