crypto

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComparePassword added in v0.8.0

func ComparePassword(hashed, password string) error

func HashPassword added in v0.8.0

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

func OptimalCost added in v0.8.0

func OptimalCost(target time.Duration) int

func ShouldUpdateCost added in v0.8.0

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

Types

type Crypto added in v0.8.0

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

func AES added in v0.8.0

func AES(key []byte) Crypto

type KeyDerivator added in v0.8.0

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

type KeySize added in v0.8.0

type KeySize int
const Key256 KeySize = 256

func (KeySize) NewDerivator added in v0.8.0

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

func (KeySize) OptimalIterations added in v0.8.0

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

type PasswordHasher added in v0.8.0

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

func NewPasswordHasher added in v0.8.0

func NewPasswordHasher(target time.Duration) PasswordHasher

Jump to

Keyboard shortcuts

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