Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidHash = stackerrors.New("the encoded hash is not in the correct format") ErrWrongHashAlgorithm = stackerrors.New("the hashing algorithm is not correct") ErrIncompatibleVersion = stackerrors.New("incompatible version of argon2") )
Functions ¶
This section is empty.
Types ¶
type Argon2ID ¶
type Argon2ID struct {
// contains filtered or unexported fields
}
Argon2ID implements the Hasher interface. Underneath, it uses the Argon2ID implementation to hash passwords and compare passwords.
func NewArgon2ID ¶
func (*Argon2ID) ComparePasswordAndHash ¶
ComparePasswordAndHash takes a password and the hash, and extracts the salt and strength parameters, and compares the hashes in constant time (avoiding time collision attacks).
func (*Argon2ID) HashPassword ¶
HashPassword takes in a password string and hashes + salts it using the Argon2ID algorithm. It is recommended that you pass in a password + pepper combination, because the pepper should be a secret value that is not stored alongside the hashed password.
The password is stored in the following format:
$argon2id$v={version}$m={memory},t={iterations},p={parallelism}${salt}${hash}
Click to show internal directories.
Click to hide internal directories.