utils

package
v1.2.40 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHash         = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
	ErrNoRandom            = errors.New("no random source available")
)

Functions

func DummyHash added in v1.2.27

func DummyHash() string

DummyHash returns a valid argon2id hash generated with the exact same code path and parameters as real password hashes. Using HashPassword (rather than a hand-crafted format string) guarantees identical salt length, key length, and encoding, which eliminates subtle timing differences in VerifyPassword that could leak whether a user account exists.

func GetConfig added in v1.2.27

func GetConfig(c *gin.Context) (*config.Config, bool)

GetConfig extracts the "Config" value from the gin context. On failure it writes an HTTP 500 response and returns nil, false.

func GetDB added in v1.2.27

func GetDB(c *gin.Context) (*gorm.DB, bool)

GetDB extracts the "DB" value from the gin context. On failure it writes an HTTP 500 response and returns nil, false.

func GetPaginatedDB added in v1.2.27

func GetPaginatedDB(c *gin.Context) (*gorm.DB, bool)

GetPaginatedDB extracts the "PaginatedDB" value from the gin context. On failure it writes an HTTP 500 response and returns nil, false.

func GetReady added in v1.2.31

func GetReady(c *gin.Context) bool

GetReady extracts the "Ready" flag from the gin context and returns its current value. On failure (missing or wrong type) it returns false.

func HashPassword

func HashPassword(password string, salt string) (string, error)

func RandomHexString added in v1.2.10

func RandomHexString(hexLen int) (string, error)

RandomHexString generates a cryptographically random hex string of the given length. The length is the number of hex characters (each character is 4 bits).

func RandomPassword

func RandomPassword(length int, minNumbers, minSpecial int) (string, error)

func VerifyPassword

func VerifyPassword(password, compareHash string, pwsalt string) (bool, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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