Documentation
¶
Overview ¶
Package argon provides secure Argon2 password hashing functionality. It supports both Argon2id (recommended) and Argon2i variants with configurable parameters.
Argon2 is a memory-hard key derivation function that won the Password Hashing Competition and is resistant to both time-memory trade-off attacks and side-channel attacks.
Example usage:
// Hash a password with default configuration
hash, err := argon.GenerateHashedPassword("mypassword", argon.DefaultConfig)
if err != nil {
log.Fatal(err)
}
// Verify a password
valid, err := argon.CompareHashAndPassword(hash, "mypassword")
if err != nil {
log.Fatal(err)
}
if valid {
fmt.Println("Password is correct")
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidHashFormat = errors.New("invalid password hash format") ErrVersionMismatch = errors.New("argon2 version mismatch") ErrInvalidPassword = errors.New("password does not match") )
Exported error types for use in conditional handling
View Source
var DefaultConfig = Config{ Type: "argon2id", Memory: 128 * 1024, Iterations: 4, Parallelism: uint8(runtime.NumCPU()), SaltLength: 32, KeyLength: 32, }
DefaultConfig provides sane, secure default values.
Functions ¶
func CompareHashAndPassword ¶
CompareHashAndPassword verifies a password against a stored hash.
Types ¶
Click to show internal directories.
Click to hide internal directories.