secure

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package secure contains the cryptographic primitives shared by the core: random identifiers, opaque secret tokens and their storage representation.

Index

Constants

View Source
const IDBytes = 16

IDBytes is the amount of entropy (in bytes) used for entity identifiers.

View Source
const TokenBytes = 32

TokenBytes is the amount of entropy (in bytes) used for opaque secret tokens.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b string) bool

Equal compares two strings in constant time.

func HashToken

func HashToken(token string) string

HashToken derives the storage/lookup representation of an opaque token.

Tokens carry 256 bits of entropy, so a fast cryptographic hash is sufficient: brute force against the hash is infeasible, and lookups stay O(1).

func NewID

func NewID() string

NewID returns a random, URL-safe, hex encoded identifier.

func NewToken

func NewToken() string

NewToken returns a random, URL-safe opaque secret token. The plaintext token must only ever be handed to the client; persist HashToken(token) instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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