hashkit

package
v0.2.41 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BCryptHasher

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

BCryptHasher implements Hasher interface. Hashes passwords using bcrypt algorithm.

func NewBCryptHasher

func NewBCryptHasher(opts ...Option) *BCryptHasher

NewBCryptHasher returns a pointer to a new instance of BCryptHasher type.

func (*BCryptHasher) CheckPassword

func (*BCryptHasher) CheckPassword(hash, pass string) error

func (*BCryptHasher) HashPassword

func (h *BCryptHasher) HashPassword(pass string) (string, error)

type Hasher

type Hasher interface {
	// HashPassword takes password and return a hasher from it.
	HashPassword(pass string) (string, error)
	// CheckPassword takes password and perform comparison with
	// stored hashed password.
	CheckPassword(hash, pass string) error
}

Hasher holds logic of hashing and checking the password.

type Option

type Option func(hasher *BCryptHasher)

func WithCost

func WithCost(cost int) Option

WithCost takes cost argument of type int and set the given value to 'BCryptHasher.cost' field. If provided cost exceed out of acceptable boundary then min or max cost wil be set.

Jump to

Keyboard shortcuts

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