A .Net wrapper for the HIBP API. The full API is supported;
- PwnedPasswords
- Breaches
- Pastes
Full credits given to Troy Hunt for creating and managing Have I been pwned?.
asyncTaskMyMethodPlainTextPasswordAsync(){varclient=newHIBP.PwnedPasswordClient("MyAwesomeService");intpwns=awaitclient.IsPasswordPwnedAsync("password1");if(pwns>0){Console.WriteLine($"Password has been pwned: {pwns} times");}}// orasyncTaskMyMethodPreHashedPasswordAsync(){varclient=newHIBP.PwnedPasswordClient("MyAwesomeService");intpwns=awaitclient.IsPasswordPwnedAsync("password1".ToSHA1(),isHash:true);if(pwns>0){Console.WriteLine("Password has been pwned");}}// for all clientspublicvoidConfigureServices(IServiceCollectionservices){services.AddHIBP(c =>{c.ApiKey=newApiKey("MyKey");c.ServiceName="MyAwesomeService";});}or you can add individual clients
publicvoidConfigureServices(IServiceCollectionservices){services.AddBreachClient(c =>{c.ApiKey=newApiKey("MyKey");c.ServiceName="MyAwesomeService";});services.AddPwnedPasswordsClient("MyAwesomeService");services.AddPastesClient(newApiKey("MyKey"),"MyAwesomeService");}Inject the client.
classMyClass{privatereadonlyIBreachClientbreachClient;publicMyClass(IBreachClientbreachClient){this.breachClient=breachClient;}publicasyncTaskGetBreachesAsync(){varbreaches=this.breachClient.GetBreachesAsync();// do stuff..}}- ApiKey has been refactored to be a class of its own. (BREAKING)
- Renamed API clients from
{name}Apito{name}Client(BREAKING) - Renamed parameters to better match usage.
- Added pastes client.
- Added extension for easier injection and setup in netcore projects.
- Expose
ToSHA1(). for easy hashing when using the PwnedPasswords API. - Update to .Net core 3.1
- Changed license from MIT to Unlicense.