util

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptoRandomBytes

func CryptoRandomBytes(length int64) ([]byte, error)

CryptoRandomBytes generates cryptographically secure random bytes

func CryptoRandomString

func CryptoRandomString(length int) (string, error)

CryptoRandomString generates a random hex string for salts

func GetIPFromContext

func GetIPFromContext(ctx context.Context) string

GetIPFromContext extracts the client IP address from the context. It first attempts to extract from Gin context (via ClientIP method), then falls back to checking for "client_ip" value set by IPMiddleware. Returns empty string if IP cannot be determined.

func HashToken

func HashToken(token, salt string) string

HashToken returns PBKDF2 hash of token with salt Parameters match Gitea's implementation for security consistency

Types

This section is empty.

Jump to

Keyboard shortcuts

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