crypto

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCost = bcrypt.DefaultCost

Variables

View Source
var (
	ErrHashFailed  = errors.New("failed to hash password")
	ErrInvalidHash = errors.New("invalid password hash format")
	ErrMismatch    = errors.New("password does not match")
)

Functions

func ConstantTimeCompare

func ConstantTimeCompare(a, b string) bool

ConstantTimeCompare compares two strings in constant time to prevent timing attacks

func GenerateAPIKey

func GenerateAPIKey(prefix string) (string, error)

GenerateAPIKey generates a prefixed API key (e.g., "lgnfy_abc123...")

func GenerateToken

func GenerateToken(length int) (string, error)

GenerateToken generates a cryptographically secure random token

func HashPassword

func HashPassword(password string) (string, error)

HashPassword hashes a password using bcrypt

func VerifyPassword

func VerifyPassword(password, hash string) error

VerifyPassword compares a password with its hash

Types

This section is empty.

Jump to

Keyboard shortcuts

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