bcrypt

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultCost is the default cost for bcrypt.
	DefaultCost = 10
)

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *types.Config

func NewBcrypt added in v0.3.18

func NewBcrypt(config *types.Config) (scheme.Scheme, error)

func WithCost added in v1.2.0

func WithCost(cost int) func(cfg *types.Config)

WithCost sets the cost parameter for the bcrypt algorithm.

Types

type Bcrypt

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

Bcrypt implements the Bcrypt hashing algorithm

func (*Bcrypt) Hash

func (c *Bcrypt) Hash(password string) (*types.HashParts, error)

Hash implements the hash method

func (*Bcrypt) HashWithSalt

func (c *Bcrypt) HashWithSalt(password string, salt []byte) (*types.HashParts, error)

HashWithSalt implements the hash with salt method WARNING: Manually concatenating salt for Bcrypt is INSECURE as Bcrypt handles salt internally. This implementation is for framework consistency, but should be used with caution.

func (*Bcrypt) Spec added in v1.1.0

func (c *Bcrypt) Spec() types.Spec

func (*Bcrypt) Verify

func (c *Bcrypt) Verify(parts *types.HashParts, password string) error

Verify implements the verify method WARNING: Manually concatenating salt for Bcrypt is INSECURE as Bcrypt handles salt internally. This implementation is for framework consistency, but should be used with caution.

type Params

type Params struct {
	Cost int
}

func DefaultParams

func DefaultParams() *Params

func FromMap added in v0.3.18

func FromMap(m map[string]string) (params *Params, err error)

FromMap parses Argon2 parameters from string

func (*Params) FromMap added in v0.3.18

func (p *Params) FromMap(params map[string]string) error

func (*Params) IsNil added in v1.1.0

func (p *Params) IsNil() bool

func (*Params) String

func (p *Params) String() string

String returns the string representation of parameters

func (*Params) ToMap added in v0.3.18

func (p *Params) ToMap() map[string]string

ToMap converts Params to a map[string]string

func (*Params) Validate added in v0.3.18

func (p *Params) Validate(config *types.Config) error

Jump to

Keyboard shortcuts

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