argon2

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMismatchedHashAndPassword is returned when password and hash do not match
	ErrMismatchedHashAndPassword = errors.New("argon2: encoded is not the hash of the given password")

	// ErrIncompatibleVersion is returned when hash versions are not compatible
	ErrIncompatibleVersion = errors.New("argon2: version is not compatible")

	// ErrInvalidHash is returned when the encoded hash has an invalid format
	ErrInvalidHash = errors.New("argon2: encoded hash has invalid format")
)

Functions

func CompareHashAndPassword

func CompareHashAndPassword(encoded []byte, password []byte) error

CompareHashAndPassword compares an argon2id hashed and encoded password with its possible plaintext equivalent. Returns nil on success, or an error on failure.

func GenerateFromPassword

func GenerateFromPassword(password []byte) ([]byte, error)

GenerateFromPassword generates a new argon2id encoded hash from the specified password

func GenerateFromPasswordWithParams

func GenerateFromPasswordWithParams(password []byte, params IDParams) ([]byte, error)

GenerateFromPasswordWithParams generates a new argon2id encoded hash from the specified password using the parameters specified

func GenerateFromPasswordWithParamsAndSalt

func GenerateFromPasswordWithParamsAndSalt(password []byte, params IDParams, salt []byte) ([]byte, error)

GenerateFromPasswordWithParamsAndSalt generates a new argon2id encoded hash from the specified password and salt using the parameters specified

func GenerateRandomBytes

func GenerateRandomBytes(size uint32) ([]byte, error)

GenerateRandomBytes generates random bytes of the specified size

Types

type IDParams

type IDParams struct {
	SaltLength  uint32
	Iterations  uint32
	Memory      uint32
	Parallelism uint8
	KeyLength   uint32
}

IDParams holds all necessary parameters to configure argon2id

var DefaultParams IDParams

DefaultParams holds resonable default parameters for argon2id

Jump to

Keyboard shortcuts

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