sec

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword

func ComparePassword(hashed, password string) error

func HashPassword

func HashPassword(password string, cost int) (string, error)

func OptimalCost

func OptimalCost(target time.Duration) int

func ShouldUpdateCost

func ShouldUpdateCost(hashed string, cost int) (bool, error)

Types

type Crypto

type Crypto interface {
	Encrypt(plain []byte) (string, error)
	Decrypt(encrypted string) ([]byte, error)
}

func AES

func AES(key []byte) Crypto

type KeyDerivator

type KeyDerivator interface {
	Derive(password string, salt []byte) []byte
}

type KeySize

type KeySize int
const Key256 KeySize = 256

func (KeySize) NewDerivator

func (size KeySize) NewDerivator(iterations int) *keyDerivator

func (KeySize) OptimalIterations

func (size KeySize) OptimalIterations(target time.Duration) int

type PasswordHasher

type PasswordHasher interface {
	Cost() int
	HashPassword(password string) (string, error)
	ComparePassword(hashed, password string) error
	ShouldUpdateCost(hashed string) (bool, error)
}

func NewPasswordHasher

func NewPasswordHasher(target time.Duration) PasswordHasher

Jump to

Keyboard shortcuts

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