go1.20.5
GoThrough

bcrypt.DefaultCost

const DefaultCost = 10

bcrypt.MaxCost

const MaxCost = 31

bcrypt.MinCost

const MinCost = 4

bcrypt.ErrHashTooShort

// The error returned from CompareHashAndPassword when a hash is too short to // be a bcrypt hash. var ErrHashTooShort = errors.New("crypto/bcrypt: hashedSecret too short to be a bcrypted password")

bcrypt.ErrMismatchedHashAndPassword

// The error returned from CompareHashAndPassword when a password and hash do // not match. var ErrMismatchedHashAndPassword = errors.New("crypto/bcrypt: hashedPassword is not the hash of the given password")

bcrypt.ErrPasswordTooLong

// ErrPasswordTooLong is returned when the password passed to // GenerateFromPassword is too long (i.e. > 72 bytes). var ErrPasswordTooLong = errors.New("bcrypt: password length exceeds 72 bytes")

bcrypt.CompareHashAndPassword

// CompareHashAndPassword compares a bcrypt hashed password with its possible // plaintext equivalent. Returns nil on success, or an error on failure. func CompareHashAndPassword(hashedPassword []byte, password []byte) error

bcrypt.Cost

// Cost returns the hashing cost used to create the given hashed // password. When, in the future, the hashing cost of a password system needs // to be increased in order to adjust for greater computational power, this // function allows one to establish which passwords need to be updated. func Cost(hashedPassword []byte) (int, error)

bcrypt.GenerateFromPassword

// GenerateFromPassword returns the bcrypt hash of the password at the given // cost. If the cost given is less than MinCost, the cost will be set to // DefaultCost, instead. Use CompareHashAndPassword, as defined in this package, // to compare the returned hashed password with its cleartext version. // GenerateFromPassword does not accept passwords longer than 72 bytes, which // is the longest password bcrypt will operate on. func GenerateFromPassword(password []byte, cost int) ([]byte, error)