password

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBCryptCostOutOfRange can be returned by NewBCryptHasher if provided cost is not between min and max.
	ErrBCryptCostOutOfRange = errors.New("password: bcrypt cost out of range")
)

Functions

This section is empty.

Types

type BCryptHasher

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

BCryptHasher hasher that use BCrypt algorithm to secure password.

func (BCryptHasher) Compare

func (bh BCryptHasher) Compare(hashedPassword, plainPassword []byte) bool

Compare implements Hasher interface.

func (BCryptHasher) Hash

func (bh BCryptHasher) Hash(plainPassword []byte) ([]byte, error)

Hash implements Hasher interface.

type Hasher

type Hasher interface {
	Hash([]byte) ([]byte, error)
	Compare([]byte, []byte) bool
}

Hasher define set of methods that object needs to implement to be considered as a hasher.

func NewBCryptHasher

func NewBCryptHasher(cost int) (Hasher, error)

NewBCryptHasher allocates new NewBCryptHasher. If cost is not between min and max value it returns an error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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