Password hashing and comparing tool
go get github.com/moonrhythm/passwordtool
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 {
// ...
}
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 {
// ...
}
MIT