hash

package
v0.7.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash               = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion       = errors.New("incompatible version of argon2")
	ErrMismatchedHashAndPassword = errors.New("passwords do not match")
)
View Source
var ErrUnknownHashAlgorithm = errors.New("unknown hash algorithm")

Functions

func Compare

func Compare(ctx context.Context, password []byte, hash []byte) error

func CompareArgon2id

func CompareArgon2id(_ context.Context, password []byte, hash []byte) error

func CompareBcrypt

func CompareBcrypt(_ context.Context, password []byte, hash []byte) error

func IsArgon2idHash

func IsArgon2idHash(hash []byte) bool

func IsBcryptHash

func IsBcryptHash(hash []byte) bool

Types

type Argon2

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

func NewHasherArgon2

func NewHasherArgon2(c Argon2Configuration) *Argon2

func (*Argon2) Generate

func (h *Argon2) Generate(ctx context.Context, password []byte) ([]byte, error)

type Argon2Configuration

type Argon2Configuration interface {
	config.Provider
}

type Bcrypt

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

func NewHasherBcrypt

func NewHasherBcrypt(c BcryptConfiguration) *Bcrypt

func (*Bcrypt) Generate

func (h *Bcrypt) Generate(ctx context.Context, password []byte) ([]byte, error)

type BcryptConfiguration

type BcryptConfiguration interface {
	config.Provider
}

type HashProvider

type HashProvider interface {
	Hasher() Hasher
}

type Hasher

type Hasher interface {
	// Generate returns a hash derived from the password or an error if the hash method failed.
	Generate(ctx context.Context, password []byte) ([]byte, error)
}

Hasher provides methods for generating and comparing password hashes.

Jump to

Keyboard shortcuts

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