token

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package token generates and hashes the random secrets moth hands out: publishable/secret API keys, admin session tokens, setup tokens.

Index

Constants

View Source
const (
	PublishableKeyPrefix = "pk_"
	SecretKeyPrefix      = "sk_"
)

Prefixes for project API keys.

View Source
const PATPrefix = "moth_pat_"

PATPrefix is the prefix of admin personal access tokens, the credential the moth CLI presents as `authorization: Bearer` metadata.

Variables

This section is empty.

Functions

func Hash

func Hash(tok string) string

Hash returns the hex SHA-256 of a token. High-entropy random tokens need no salt or slow KDF.

func New

func New(prefix string) string

New returns prefix + 26 random characters (130 bits of entropy).

func Random

func Random(n int) string

Random returns n random bytes encoded as lowercase base32.

Types

This section is empty.

Jump to

Keyboard shortcuts

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