hashing

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const Md5Prefix = "$md5$"

Variables

View Source
var DefaultArgon2idHasher = &Argon2idHasher{Params: argon2id.DefaultParams}
View Source
var DefaultBcryptHasher = &BcryptHasher{Cost: bcrypt.DefaultCost}
View Source
var ErrUnknownHasher = errors.New("unknown hasher")

Functions

func IsDeprecated added in v0.1.7

func IsDeprecated(hasher string) bool

func MarkDeprecated added in v0.1.7

func MarkDeprecated(hasher string, hashers ...string)

func UnmarkDeprecated added in v0.1.7

func UnmarkDeprecated(hasher string, hashers ...string)

Types

type Argon2idHasher

type Argon2idHasher struct {
	Params *argon2id.Params
}

func (*Argon2idHasher) Check

func (h *Argon2idHasher) Check(value string, hashedValue string) (bool, error)

func (*Argon2idHasher) Make

func (h *Argon2idHasher) Make(value string) (string, error)

func (*Argon2idHasher) NeedsRehash

func (h *Argon2idHasher) NeedsRehash(hashedValue string) bool

type BcryptHasher

type BcryptHasher struct {
	Cost int
}

func (*BcryptHasher) Check

func (h *BcryptHasher) Check(value string, hashedValue string) (bool, error)

func (*BcryptHasher) Make

func (h *BcryptHasher) Make(value string) (string, error)

func (*BcryptHasher) NeedsRehash

func (h *BcryptHasher) NeedsRehash(hashedValue string) bool

type Hasher

type Hasher interface {
	Make(value string) (string, error)
	Check(value string, hashedValue string) (bool, error)
	NeedsRehash(hashedValue string) bool
}

type HasherManager

type HasherManager struct {
	DefaultHasher string
	Hashers       map[string]Hasher
	MapHashPrefix map[string]string
}

func NewHasherManager

func NewHasherManager() *HasherManager

func (*HasherManager) Check

func (m *HasherManager) Check(value string, hashedValue string) (bool, error)

func (*HasherManager) IdentifyHasher

func (m *HasherManager) IdentifyHasher(hashedValue string) (string, bool)

func (*HasherManager) Make

func (m *HasherManager) Make(value string) (string, error)

func (*HasherManager) NeedsRehash

func (m *HasherManager) NeedsRehash(hashedValue string) bool

func (*HasherManager) RegisterHasher added in v0.1.7

func (m *HasherManager) RegisterHasher(hasher string, h Hasher, prefix string)

type Md5Hasher added in v0.1.7

type Md5Hasher struct {
	Callback func(value string) (string, error)
}

func (*Md5Hasher) Check added in v0.1.7

func (h *Md5Hasher) Check(value string, hashedValue string) (bool, error)

func (*Md5Hasher) Make added in v0.1.7

func (h *Md5Hasher) Make(value string) (string, error)

func (*Md5Hasher) NeedsRehash added in v0.1.7

func (h *Md5Hasher) NeedsRehash(hashedValue string) bool

Jump to

Keyboard shortcuts

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