Help us shape the future of Go! Take the 2026 Go Developer Survey

randomtoken

package
v0.5.3 Latest Latest
Warning

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

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

Documentation

Overview

Package randomtoken supplies bounded cryptographically random opaque values. Encoded tokens use secret.String; revealing one for transmission is explicit.

Index

Constants

View Source
const MaxBytes = 4096

Variables

This section is empty.

Functions

func Base64

func Base64(size int) (secret.String, error)

Base64 encodes size random bytes using unpadded URL-safe base64.

func Bytes

func Bytes(size int) ([]byte, error)

Bytes returns independent entropy, with size in [1, MaxBytes]. Unlike encoded tokens these raw bytes have no automatic formatting redaction.

func Generate

func Generate(length int) (secret.String, error)

Generate produces exactly length alphanumeric characters. Rejection sampling avoids modulo bias. Length is a character count, not a number of entropy bytes.

func Hex

func Hex(size int) (secret.String, error)

Hex returns random bytes encoded as a hexadecimal secret, propagating generation errors.

Types

This section is empty.

Jump to

Keyboard shortcuts

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