bcrypt

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Identifier = "2"
	Prefix     = "$" + Identifier
)

Identifier and prefix used by Bcrypt

View Source
const (
	DefaultMinCost = bcrypt.MinCost
	DefaultMaxCost = bcrypt.MaxCost
	DefaultCost    = bcrypt.DefaultCost
)

Variables

View Source
var DefaultValidationOpts = ValidationOpts{
	MinCost: DefaultMinCost,
	MaxCost: DefaultMaxCost,
}
View Source
var (
	Versions = [...]byte{'a', 'b', 'y'}
)

Versions of the Bcrypt implementation.

Functions

This section is empty.

Types

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher hashes and verifies bcrypt passwords.

func New

func New(cost int, opts *ValidationOpts) *Hasher

New will return a Hasher with cost as bcrypt parameter.

func (*Hasher) Hash

func (h *Hasher) Hash(password string) (string, error)

Hash implements passwap.Hasher.

func (*Hasher) Validate added in v0.12.0

func (h *Hasher) Validate(encoded string) (verifier.Result, error)

func (*Hasher) Verify

func (h *Hasher) Verify(encoded, password string) (verifier.Result, error)

Verify implements passwap.Verifier

type ValidationOpts added in v0.12.0

type ValidationOpts struct {
	MinCost int
	MaxCost int
}

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

func NewVerifier added in v0.12.0

func NewVerifier(opts *ValidationOpts) *Verifier

func (*Verifier) Validate added in v0.12.0

func (v *Verifier) Validate(encoded string) (verifier.Result, error)

func (*Verifier) Verify added in v0.12.0

func (v *Verifier) Verify(encoded, password string) (verifier.Result, error)

Verify parses encoded and uses its bcrypt parameters to verify password against its hash.

Jump to

Keyboard shortcuts

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