bcrypt

package
v0.0.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinCost     int = 4
	MaxCost     int = 31
	DefaultCost int = 10
)
View Source
const (
	ErrHashTooShort              Error = "bcrypt: hash too short"
	ErrMismatchedHashAndPassword Error = "bcrypt: hashedPassword is not the hash of the given password"
	ErrCostTooLow                      = "bcrypt: cost %d is below the minimum %d"
	ErrCostTooHigh                     = "bcrypt: cost %d is above the maximum %d"
	ErrHashVersionTooNew               = "bcrypt: hash version '%c' is not supported"
	ErrPasswordTooLong           Error = "bcrypt: password exceeds 72 bytes"
	ErrInvalidHashPrefix               = "bcrypt: hash must start with '$', got '%c'"
)

Variables

This section is empty.

Functions

func CompareHashAndPassword

func CompareHashAndPassword(hashedPassword, password []byte) error

CompareHashAndPassword compares a bcrypt hash with a candidate plaintext password.

func Cost

func Cost(hashedPassword []byte) (int, error)

Cost returns the cost used to create the given hash.

func GenerateFromPassword

func GenerateFromPassword(password []byte, cost int) ([]byte, error)

GenerateFromPassword returns the bcrypt hash of the password at the given cost.

Types

type Error

type Error string

func (Error) Error

func (e Error) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL