hash

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package hash is build to support multiple hashing algorithms with different parameters across projects.

Index

Constants

View Source
const (
	BcryptMinCost     = bcrypt.MinCost
	BcryptMaxCost     = bcrypt.MaxCost
	BcryptDefaultCost = bcrypt.DefaultCost
)

Variables

View Source
var (
	ErrBcryptCostMinValue = errors.InvalidArgumentErrorf("bcrypt cost myst be a minimum of %d", BcryptMinCost)
	ErrBcryptCostMaxValue = errors.InvalidArgumentErrorf("bcrypt cost myst be a maximum of %d", BcryptMaxCost)
)
View Source
var DefaultBcrypt = &model.BcryptHashingConfig{
	Cost: int32(BcryptDefaultCost),
}
View Source
var DefaultScrypt = &model.ScryptHashingConfig{
	SignerKey:     "",
	SaltSeparator: "Bw==",
	Rounds:        8,
	MemCost:       14,
	P:             1,
	KeyLen:        32,
}

Functions

func Key

func Key(password, salt []byte, cfg *model.ScryptHashingConfig) ([]byte, error)

Types

type Hash

type Hash interface {
	Generate(password string) (*model.HashingInstance, error)
	Compare(password string, hashModel *model.HashingInstance) error
}

func New

func New(config *model.HashingConfig) Hash

Jump to

Keyboard shortcuts

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