argon2

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMemory     uint32 = 64 * 1024
	DefaultIterations uint32 = 1
	DefaultThreads    uint8  = 4
)

Variables

This section is empty.

Functions

func WithIterations added in v1.2.0

func WithIterations(iterations uint32) types.Option

WithIterations configure the iterations for Encoder, default value is 1

func WithKeyLen

func WithKeyLen(len uint32) types.Option

WithKeyLen configure the key length for Encoder, default value is 32

func WithMemory

func WithMemory(memory uint32) types.Option

WithMemory configure the memory for Encoder, default value is 64 * 1024

func WithSalt

func WithSalt(salt []byte) types.Option

WithSalt configure the salt value for Encoder, default automatically generate random strings

func WithSaltLen

func WithSaltLen(len uint32) types.Option

WithSaltLen configure the salt length for Encoder, default value is 16

func WithThreads

func WithThreads(threads uint8) types.Option

WithThreads configure the Threads for Encoder, default value is 4

Types

type Encoder

type Encoder struct {
	// The amount of memory used by the algorithm (in kibibytes).
	Memory uint32
	// The number of iterations over the memory.
	Iterations uint32
	// The number of threads (or lanes) used by the algorithm.
	// Recommended value is between 1 and runtime.NumCPU().
	Threads uint8
	// Length of the random salt. 16 bytes is recommended for password hashing.
	SaltLen uint32
	// Length of the generated key. 16 bytes or more is recommended.
	KeyLen uint32
	// contains filtered or unexported fields
}

func (*Encoder) Encode

func (e *Encoder) Encode(src string) (string, error)

Encode returns the hash value of the given data

func (*Encoder) GetSalt

func (e *Encoder) GetSalt() ([]byte, error)

GetSalt Returns the salt if present, otherwise nil

func (*Encoder) Hash added in v1.2.2

func (e *Encoder) Hash(src string) ([]byte, error)

Hash Generate and return a hash value in []byte format

func (*Encoder) Verify

func (e *Encoder) Verify(hash, rawData string) (bool, error)

Verify compares a encoded data with its possible plaintext equivalent

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL