argon2

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(encoded, password string) (bool, error)

CheckPasswordHash verifies if a given plain password matches the Base58-encoded hash. Returns true if they match, false otherwise.

func HashPassword

func HashPassword(password string, p *Params) (string, error)

HashPassword generates a secure, encoded Argon2ID hash string using Base58. It marshals the hash, salt, and params into a JSON structure and encodes it. Returns a Base58 encoded string safe to store in databases or configuration.

Types

type Hash

type Hash struct {
	Data   []byte  `json:"data"`
	Salt   []byte  `json:"salt"`
	Params *Params `json:"params"`
}

Hash represents the encoded structure used to store a hashed password, including the derived hash, salt, and the parameters used.

type Params

type Params struct {
	Memory      uint32 `json:"m"` // Memory in KB
	Iterations  uint32 `json:"i"` // Number of iterations
	Parallelism uint8  `json:"p"` // Number of parallel threads
	SaltLength  uint32 `json:"s"` // Length of the random salt
	KeyLength   uint32 `json:"k"` // Desired length of the resulting key
}

Params holds configuration for the Argon2ID hash function. It includes memory usage, number of iterations, parallelism, salt length, and resulting key length.

Jump to

Keyboard shortcuts

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