Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 1.15 KB

File metadata and controls

61 lines (47 loc) · 1.15 KB

passwordtool

codecov Go Report Card GoDoc

Password hashing and comparing tool

Install

go get github.com/moonrhythm/passwordtool

Usage

hashed, err := passwordtool.Hash("superman")
if err != nil {
	// ...
}
fmt.Println(hashed)

err = passwordtool.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

Specific algorithm

hc := passwordtool.Bcrypt{Cost: 11}
hashed, err := hc.Hash("superman")
if err != nil {
	// ...
}

err = hc.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

// or

err = passwordtool.Compare(hashed, "superman")
if err == passwordtool.ErrMismatched {
	// not equal
}
if err != nil {
	// ...
}

License

MIT