random

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package random provides cryptographically secure random number and string generation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(length int) (string, error)

Bytes generates random bytes and returns them as a base64-encoded string.

func Float

func Float() float64

Float generates a random float64 between 0.0 and 1.0.

func Hex

func Hex(length int) (string, error)

Hex generates random bytes and returns them as a hex-encoded string.

func ID

func ID() string

ID generates a globally unique sortable ID using xid. Returns a 20-character string that is smaller than UUID and sortable by creation time.

func Int

func Int(min, max int) (int, error)

Int generates a cryptographically secure random integer between min and max (inclusive). Falls back to math/rand on crypto/rand errors.

func String

func String(length int) (string, error)

String generates a random alphanumeric string of the specified length.

Types

This section is empty.

Jump to

Keyboard shortcuts

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