Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidHash = errors.New("invalid hash") ErrIncompatibleVersion = errors.New("incompatible version") )
Functions ¶
func GenerateNonce ¶
GenerateNonce returns an array of cryptographically randomly generated bytes with the given entropy.
func GenerateURLSafeNonce ¶
GenerateURLSafeNonce returns a base64 url encoded nonce with the given bytes of entropy.
Types ¶
type Argon2 ¶
type Argon2 struct {
// contains filtered or unexported fields
}
func NewArgon2 ¶
func NewArgon2(opts ...Argon2Option) *Argon2
NewArgon2 returns a new instance of the Argon2 password provider.
Defaults:
- memory: 64MB
- time: 3
- threads: 2
- salt length: 16
- key length: 32
func (*Argon2) ComparePasswordAndHash ¶
ComparePasswordAndHash compares the given password and hash to see if they match.
func (*Argon2) GenerateFromPassword ¶
GenerateFromPassword hashes the given password and returns the hash.
type Argon2Option ¶
type Argon2Option func(*Argon2)
Argon2Option provides a functional way to configure the argon2 password provider
func WithKeyLength ¶
func WithKeyLength(length uint32) Argon2Option
WithKeyLength sets the length of the raw key to be generated. The value 0 is ignored.
func WithMemory ¶
func WithMemory(memory uint32) Argon2Option
WithMemory sets the memory cost. The value 0 is ignored.
func WithSaltLength ¶
func WithSaltLength(length uint32) Argon2Option
WithSaltLength sets the length of the raw salt to be generated. The value 0 is ignored.
func WithThreads ¶
func WithThreads(threads uint8) Argon2Option
WithThreads sets the number of threads to be used. The value 0 is ignored.
func WithTime ¶
func WithTime(time uint32) Argon2Option
WithTime sets the time cost. The value 0 is ignored.