Skip to content

Go package that returns information on whether a given password has been involved in a data breach using https://haveibeenpwned.com

License

Notifications You must be signed in to change notification settings

masonj5n/pwchecker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pwchecker

Go Report Card

Exports a single function:

func CheckForPwnage(pw string) (*Pwd, error)

The function checks the password using the https://haveibeenpwned.com API.

It returns a pointer to a struct like so:

type Pwd struct {
	Pwnd   bool
	Pwd    string
	TmPwnd string
}

Pwnd is true if the password has been pwned.
Pwd is the original password passed to the fucntion.
TmPwnd is a string with the number of times the password has been pwned.

Example Usage:

func Example() {
	userPass := form.Data("password")

	pwdCheck, err := pwchecker.CheckForPwnage(userPass)
	if err != nil {
		fmt.Println("Password Check error: %s", err)
	}
	if pwdCheck.Pwnd {
		fmt.Println("Password is found in database")
	}
}

About

Go package that returns information on whether a given password has been involved in a data breach using https://haveibeenpwned.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages