package module
Version: v0.0.0-...-0a6c5b7 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2018 License: Apache-2.0 Imports: 9 Imported by: 0



Documentation Build Status Go Report Card Coverage Status

haveibeenpwned API in go.



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.




This section is empty.


View Source
var ErrRateLimited = errors.New("rate limit exceeded")

ErrRateLimited is returned when request limit is exceeded, wait for 2sec before sending another request


func DataClasses

func DataClasses() ([]string, error)

DataClasses returns all data classes present in the system

func Password

func Password(password string) (int, error)

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

n, err := Password("12345678")
if err != nil {
fmt.Printf("This password has been pwned %d times.\n", n)

This password has been pwned 2840404 times.


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

BreachByAccount("test@example.com", nil)

Example (TruncateBody)
BreachByAccount("test@example.com", &SearchOptions{
	NameOnly: true,

func BreachByName

func BreachByName(name string) (*Breach, error)

BreachByName fetches the information regarding a breach

func Breaches

func Breaches() ([]Breach, error)

Breaches fetches all breaches in the system

func BreachesByDomain

func BreachesByDomain(domain string) ([]Breach, error)

BreachesByDomain fetches breaches regarding a particular domain in the system

type Paste

type Paste struct {
	Source     string
	ID         string `json:"Id"`
	Title      string
	Date       string
	EmailCount int

Paste is info regarding a paste https://haveibeenpwned.com/API/v2#PasteModel

func PasteAccount

func PasteAccount(email string) ([]Paste, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL