argon2id

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

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

Go to latest
Published: Nov 11, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCost = Cost{
	Time:    3,
	Memory:  128 * 1024,
	Threads: 2,
	KeyLen:  32,
	SaltLen: 32,
}

DefaultCost for argon2id

View Source
var ErrInvalidHash = errors.New("argon2id/parse: Hash is not argon2id")

ErrInvalidHash returned when hash is not argon2id

View Source
var ErrMismatchedHashAndPassword = errors.New("utils/password/compare.go: Mismatched hashedPassword and password")

ErrMismatchedHashAndPassword returned when no account is found

Functions

This section is empty.

Types

type Cost

type Cost struct {
	Time    uint32 `json:"time"`
	Memory  uint32 `json:"memory"`
	Threads uint8  `json:"threads"`
	KeyLen  uint32 `json:"keyLen"`
	SaltLen int32  `json:"saltLen"`
}

Cost for argon2id

func (*Cost) FillEmpty

func (c *Cost) FillEmpty()

FillEmpty override struct defaults with DefaultCost

type Password

type Password struct {
	Version int
	Cost    Cost
	Salt    []byte
	Key     []byte
}

Password Argon2ID password struct

func Hash

func Hash(password string, c Cost) *Password

Hash password with argon2id

func HashSalt

func HashSalt(password string, salt []byte, c Cost) *Password

HashSalt provide salt to hash password with argon2id

func Parse

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

Parse formated password return password struct

func (*Password) Compare

func (p *Password) Compare(password string) error

Compare Password struct with plaintext password

func (*Password) NeedRehash

func (p *Password) NeedRehash(cost Cost) bool

NeedRehash checks hash values to

func (*Password) Parse

func (p *Password) Parse(password string) (string, error)

Parse formated password to fill Password struct

func (*Password) ToString

func (p *Password) ToString() string

ToString returns a formated argon2id string $argon2id$v=19$$m={memory},t={time},p={threads}${salt}${key}

func (*Password) ToStringNoKey

func (p *Password) ToStringNoKey() string

ToStringNoKey returns a formated argon2id string without key $argon2id$v=19$$m={memory},t={time},p={threads}${salt}${key}

Jump to

Keyboard shortcuts

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