CheckPassword
Overview
CheckPassword reports whether password matches the bcrypt hash.
If you are coming from Node.js, the closest pattern is bcrypt.compare(password, hash).
Signature
go
func CheckPassword(password, hash string) boolCompare: Node.js · Standard Go · gox
js
bcrypt.compare(password, hash)go
hash, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost)go
import "github.com/sahilkhaire/gox/crypto"
crypto.CheckPassword(password, hash)Example
go
import "github.com/sahilkhaire/gox/crypto"
crypto.CheckPassword(password, hash)Tips
Import github.com/sahilkhaire/gox/crypto and call CheckPassword directly. See the comparison below for the standard library equivalent.
Standard library alternative
Use the standard library directly:
go
hash, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.DefaultCost)