Packages

A simple application to check if an email or password has been pwned using the HaveIBeenPwned? API. It requires a purchased hibp-api-key in order to use the email checking functions.

Current section

Files

Jump to
pwned_coretheory lib range http_client.ex
Raw

lib/range/http_client.ex

defmodule Pwned.Range.HTTPClient do
@moduledoc """
Uses the API V3 pwnedpasswords to check if
a password has been pwned.
Updated to include padding to increase privacy.
"""
@behaviour Pwned.Range
def get(head) do
case HTTPoison.get("https://api.pwnedpasswords.com/range/#{head}", [{"Add-Padding", "true"}]) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
{:ok, body}
_ ->
:error
end
end
end