password

package
v0.0.0-...-1ba6274 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Variant = "argon2id"

Variables

View Source
var (
	ErrInvalidHash         = errors.New("invalid hash")
	ErrIncompatibleVariant = errors.New("incompatible variant")
	ErrIncompatibleVersion = errors.New("incompatible version")
)

Functions

func Check

func Check(plaintext, hashed string) (bool, error)

Check that the plaintext and hashed string match.

func Compare

func Compare(plaintext string, pwd Password) (bool, error)

Compare a plaintext string and the Password type. Return their results or any errors.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

func Iterations

func Iterations(it uint32) Option

func KeyLength

func KeyLength(length uint32) Option

func Memory

func Memory(mem uint32) Option

func MemoryInMB

func MemoryInMB(m uint32) Option

func Parallelism

func Parallelism(p uint8) Option

func SaltLength

func SaltLength(length int) Option

type Password

type Password struct {
	Variant     string
	Version     int
	Memory      uint32
	Iterations  uint32
	Parallelism uint8
	Salt        []byte
	Key         []byte
}

func Create

func Create(pwd string, opts ...Option) (*Password, error)

Create a password.

func Parse

func Parse(hash string) (*Password, error)

Parse will take a string attempt to parse a Password from it.

func (Password) String

func (p Password) String() string

Jump to

Keyboard shortcuts

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