pwchecker

package module
v0.0.0-...-a067825 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Unlicense Imports: 9 Imported by: 0

README

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")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPassphraseEmpty indicates passphrase input was less than 1 character
	ErrPassphraseEmpty = errors.New("Passphrase Input Empty")
)

Functions

This section is empty.

Types

type Pwd

type Pwd struct {
	Pwnd   bool   // Pwnd returns true if passphrase is found pwned via API
	Pwd    string // Pwd returns the passphrase string passed to the function
	TmPwnd string // TmPwnd returns the number of times the passphrase was found in the database
}

Pwd is returned as a struct pointer when calling CheckForPwnage

func CheckForPwnage

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

CheckForPwnage takes passphrase as string, sends request to API and returns Pwd and error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL