Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidHash = errors.New("the encoded hash is not in the correct format") ErrIncompatibleVersion = errors.New("incompatible version of argon2") ErrInvalidPassword = errors.New("password cannot be empty") // Minimum and maximum parameter bounds MinMemory uint32 = 8 * 1024 // 8MB minimum MaxMemory uint32 = 1024 * 1024 // 1GB maximum MinIterations uint32 = 1 MaxIterations uint32 = 100 MinParallelism uint8 = 1 MaxParallelism uint8 = 255 )
View Source
var DefaultParams = &Params{
Memory: 64 * 1024,
Iterations: 3,
Parallelism: 2,
SaltLength: 16,
KeyLength: 32,
}
DefaultParams sets the default parameters for Argon2 hashing.
Functions ¶
func ComparePassAndHash ¶
ComparePassAndHash compares a password to an encoded hash to verify if they match. It returns true if the password matches the hash, otherwise false.
func GenerateRandomString ¶
GenerateRandomString generates a secure random string of the specified length
func HashPassword ¶
HashPassword hashes a password using Argon2 and the specified parameters. It returns the encoded hash or an error if hashing fails.
func ValidateParams ¶
ValidateParams validates the Argon2 parameters are within acceptable bounds.
Types ¶
Click to show internal directories.
Click to hide internal directories.