Documentation ¶
Overview ¶
Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing algorithm. See http://www.usenix.org/event/usenix99/provos/provos.pdf
Index ¶
Constants ¶
const ( MinCost int = 4 // the minimum allowable cost as passed in to GenerateFromPassword MaxCost int = 31 // the maximum allowable cost as passed in to GenerateFromPassword DefaultCost int = 10 // the cost that will actually be set if a cost below MinCost is passed into GenerateFromPassword )
Variables ¶
var ErrHashTooShort = errors.New("crypto/bcrypt: hashedSecret too short to be a bcrypted password")
The error returned from CompareHashAndPassword when a hash is too short to be a bcrypt hash.
var ErrMismatchedHashAndPassword = errors.New("crypto/bcrypt: hashedPassword is not the hash of the given password")
The error returned from CompareHashAndPassword when a password and hash do not match.
Functions ¶
func CompareHashAndPassword ¶
CompareHashAndPassword compares a bcrypt hashed password with its possible plaintext equivalent. Note: Using bytes.Equal for this job is insecure. Returns nil on success, or an error on failure.
func 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 MinCost, instead. Use CompareHashAndPassword, as defined in this package, to compare the returned hashed password with its cleartext version.
Types ¶
type HashVersionTooNewError ¶
type HashVersionTooNewError byte
The error returned from CompareHashAndPassword when a hash was created with a bcrypt algorithm newer than this implementation.
func (HashVersionTooNewError) Error ¶
func (hv HashVersionTooNewError) Error() string
type InvalidCostError ¶
type InvalidCostError int
func (InvalidCostError) Error ¶
func (ic InvalidCostError) Error() string
type InvalidHashPrefixError ¶
type InvalidHashPrefixError byte
The error returned from CompareHashAndPassword when a hash starts with something other than '$'
func (InvalidHashPrefixError) Error ¶
func (ih InvalidHashPrefixError) Error() string