Documentation ¶
Overview ¶
Package hibp is haveibeenpwned api written in go
All APIs returns default value(0 for int, nil for slices and pointers) with nil error if the specified data could not be found.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRateLimited = errors.New("rate limit exceeded")
ErrRateLimited is returned when request limit is exceeded, wait for 2sec before sending another request
Functions ¶
func DataClasses ¶
DataClasses returns all data classes present in the system
func Password ¶
Password finds how many times a password has been pwned. The password is hashed with SHA1 and only the first 5 hash characters(20 bits) is sent to the server
Example ¶
n, err := Password("12345678") if err != nil { panic(err) } fmt.Printf("This password has been pwned %d times.\n", n)
Output: This password has been pwned 2840404 times.
Types ¶
type Breach ¶
type Breach struct { Name string Title string Domain string BreachData string AddedDate string ModifiedDate string PwnCount int Description string LogoPath string DataClasses []string IsVerified bool IsFabricated bool IsSensitive bool IsRetired bool IsSpamList bool }
Breach is info regarding a breach https://haveibeenpwned.com/API/v2#BreachModel
func BreachByAccount ¶
func BreachByAccount(account string, opt *SearchOptions) ([]Breach, error)
BreachByAccount searches a particular account for breaches
Example ¶
BreachByAccount("test@example.com", nil)
Output:
Example (TruncateBody) ¶
BreachByAccount("test@example.com", &SearchOptions{ NameOnly: true, })
Output:
func BreachByName ¶
BreachByName fetches the information regarding a breach
func BreachesByDomain ¶
BreachesByDomain fetches breaches regarding a particular domain in the system
type Paste ¶
Paste is info regarding a paste https://haveibeenpwned.com/API/v2#PasteModel
func PasteAccount ¶
PasteAccount searches for occurrences of a certain email in pastebins
type SearchOptions ¶
type SearchOptions struct { // NameOnly truncates all other fields but the Name field. NameOnly bool // IncludeUnverified includes unverified breaches in the response IncludeUnverified bool // Domain filters the response by domain Domain string }
SearchOptions defines detailed options in a BreachByAccount search