secure

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package secure provides utilities for generating and handling cryptographically secure tokens intended for authentication, API keys, and other security-sensitive use cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(value string) string

Fingerprint returns a short BLAKE2b-derived fingerprint for display purposes.

func Hash

func Hash(value string) string

Hash returns the BLAKE2b-256 hash of the given value as a hex-encoded string.

func MustRandomHex

func MustRandomHex(n int) string

MustRandomHex returns n cryptographically secure random bytes as a hex-encoded string. Returns 2*n hex characters. Suitable for request IDs, boundaries, and nonces. Panics on random source failure (indicates system-level issue).

func NewAPIToken

func NewAPIToken() (string, error)

NewAPIToken generates a cryptographically secure token for API authentication. Returns a prefixed token in the format beebuzz_api_<token>.

func NewDeviceToken

func NewDeviceToken() (string, error)

NewDeviceToken generates a cryptographically secure token for device authentication. Returns a prefixed token in the format beebuzz_device_<token>.

func NewInspectToken

func NewInspectToken() (string, error)

NewInspectToken generates a cryptographically secure token for webhook inspect sessions. Returns a prefixed token in the format beebuzz_whi_<token>.

func NewOTP

func NewOTP() (string, error)

NewOTP generates a cryptographically secure 6-digit one-time password.

func NewSessionToken

func NewSessionToken() (string, error)

NewSessionToken generates a cryptographically secure token for user sessions. Returns a prefixed token in the format beebuzz_session_<token>.

func NewWebhookToken

func NewWebhookToken() (string, error)

NewWebhookToken generates a cryptographically secure token for webhook endpoints. Returns a prefixed token in the format beebuzz_wh_<token>.

func Verify

func Verify(token, hash string) bool

Verify reports whether the hash of token matches the given hash. Uses constant time comparison to prevent timing attacks.

Types

This section is empty.

Jump to

Keyboard shortcuts

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