Documentation
¶
Overview ¶
Package hibp is the library behind the hibp command line: the HTTP client, request shaping, and the typed data models for the HaveIBeenPwned Pwned Passwords API.
The Client uses k-anonymity: only the first 5 characters of a SHA1 hash are sent to the API, so the full password is never transmitted.
Index ¶
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "hibp-cli/0.1.0 (github.com/tamnd/hibp-cli)"
DefaultUserAgent identifies the client to the API.
const Host = "api.pwnedpasswords.com"
Host is the API host.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶
type CheckResult struct {
Password string `json:"password"` // masked: first 2 + "..." + last 2, or all "*"
SHA1Prefix string `json:"sha1_prefix"` // first 5 chars sent to API
PwnedCount int `json:"pwned_count"` // 0 = not found
Pwned bool `json:"pwned"`
}
CheckResult is the output of a password check.
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
BaseURL string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to the HIBP Pwned Passwords API.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from a Config.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds the client configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the HIBP Pwned Passwords API.
type Domain ¶
type Domain struct{}
Domain is the hibp driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.