argon2/options.go
euphoria-laxis c32e66bd1e
All checks were successful
test argon2 package / check and test (pull_request) Successful in 19m15s
test argon2 package / check and test (push) Successful in 28m40s
Set version and remove subpackages
2024-11-28 22:04:03 +01:00

56 lines
1.1 KiB
Go

package argon2
import "errors"
type Options struct {
Memory uint32
Iterations uint32
Parallelism uint8
SaltLength uint32
KeyLength uint32
}
var (
ErrInvalidHash = errors.New("the encoded hash is not in the correct format")
ErrIncompatibleVersion = errors.New("incompatible version of argon2")
defaultOptions = Options{
Memory: 64 * 1024,
Iterations: 3,
Parallelism: 2,
SaltLength: 16,
KeyLength: 32,
}
)
type OptFunc func(*Options)
func SetMemory(memory uint32) OptFunc {
return func(options *Options) {
options.Memory = memory
}
}
func SetIterations(iterations uint32) OptFunc {
return func(options *Options) {
options.Iterations = iterations
}
}
func SetParallelism(parallelism uint8) OptFunc {
return func(options *Options) {
options.Parallelism = parallelism
}
}
func SetSaltLength(saltLength uint32) OptFunc {
return func(options *Options) {
options.SaltLength = saltLength
}
}
func SetKeyLength(keyLength uint32) OptFunc {
return func(options *Options) {
options.KeyLength = keyLength
}
}