argon2id

package module
v0.0.0-...-38f9c22 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 6 Imported by: 1

README

Argon2id

Argon2id is a wrapper library around the golang.org/x/crypto/argon2 library that provides a set of simple methods for handling passwords hashed with the Argon2id key derivation function.

Documentation

Documentation can be found here.

Testing

Argon2id can be tested with:

go test

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorInvalidHash indicates that the provided hash does not conform to
	// any argon2 standard.
	ErrorInvalidHash = fmt.Errorf("argon2id: invalid hash provided")

	// ErrorInvalidVersion indicates that the provided has may be an argon hash
	// but is not an argon2id hash.
	ErrorInvalidVersion = fmt.Errorf("argon2id: non argon2id hash provided")

	// ErrorPasswordMismatch indicates that the provided hash and password do
	// not match.
	ErrorPasswordMismatch = fmt.Errorf("argon2id: password did not match")
)

Functions

func CompareHashAndPassword

func CompareHashAndPassword(hash, password []byte) error

CompareHashAndPassword compares a hashed Argon2id password with a possible plaintext equivalent. Returns nil on success, or an error on failure.

func GenerateFromPassword

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

GenerateFromPassword takes a password and parameter struct and encodes the password with Argon2id, based on the parameters set in the struct.

Types

type Parameters

type Parameters struct {
	Time    uint32
	Memory  uint32
	Threads uint8
	Length  uint32
	Salt    []byte
}

Parameters is a collection of parameters that control the output of the hash.

func GetParametersFromHash

func GetParametersFromHash(hash []byte) (Parameters, error)

GetParametersFromHash will read an Argon2id hash and return a parameters object with the parameters that were used to generate the hash.

func NewParameters

func NewParameters(
	time uint32,
	memory uint32,
	threads uint8,
	length uint32,
) (Parameters, error)

NewParameters genreates a new Parameters struct and initializes it with the provided values and a randomly generated salt.

Jump to

Keyboard shortcuts

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