Documentation
¶
Overview ¶
Package argon2id provides a wrapper around Go's argon2 using the argon2id variant. It provides multiple helper functions to make a secure implementation easier.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPasswordRequired is returned by HashPassword or VerifyPassword if no // password was provided. ErrPasswordRequired = errors.New("argon2id: password must not be empty.") // ErrSaltRequired is returned by HashPassword if no salt was provided. ErrSaltRequired = errors.New("argon2id: salt must not be empty.") // ErrArgon2KeyRequired is returned by VerifyPassword if no argon2 key was // provided. ErrArgon2KeyRequired = errors.New("argon2id: argon2 key must not be empty.") // ErrInvalidKeyLength is returned by VerifyPassword if the provided argon2 // key is of invalid length. ErrInvalidKeyLength = errors.New("argon2id: argon2 key invalid length.") // ErrArgonVersionMismatch is returned by VerifyPassword if the provided // argon2 key version is different than the one used by the package. ErrArgonVersionMismatch = errors.New("argon2id: argon2 key version mismatch.") // ErrHashNotEqualPassword is returned by VerifyPassword if the provided // hash does not equal the password. ErrHashNotEqualPassword = errors.New("argon2id: hash not equal password.") )
var DefaultOptions = &Options{
Time: 1,
Memory: 64 * 1024,
Threads: 4,
KeyLen: 32,
}
DefaultOptions contains sane defaults as of December 2021. These defaults are subject to change if new recommendations are released. These settings were chosen for usage in a web application.
Functions ¶
func DecodeBase64String ¶
DecodeBase64String is a helper function that decodes the given base64 string.
func EncodeToBase64String ¶
EncodeToBase64String is a helper function that turns the given bytes into a base64 encoded string.
func HashPassword ¶
HashPassword takes a password and a salt and returns an argon2 key that can be saved in a database.
func VerifyPassword ¶
VerifyPassword takes a password and an argon2 key and compares both. It will return an error if they are not equal.