cryptorand

package
v2.29.25 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// Numeric includes decimal numbers (0-9)
	Numeric = "0123456789"

	// Upper is uppercase characters in the Latin alphabet
	Upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

	// Lower is lowercase characters in the Latin alphabet
	Lower = "abcdefghijklmnopqrstuvwxyz"

	// Alpha is upper or lowercase alphabetic characters
	Alpha = Upper + Lower

	// Default is uppercase, lowercase, or numeric characters
	Default = Numeric + Alpha

	// Hex is hexadecimal lowercase characters
	Hex = "0123456789abcdef"

	// Human creates strings which are easily distinguishable from
	// others created with the same charset. It contains most lowercase
	// alphanumeric characters without 0,o,i,1,l.
	Human = "23456789abcdefghjkmnpqrstuvwxyz"
)

Charsets

Variables

This section is empty.

Functions

func Element

func Element[T any](s []T) (out T, err error)

Element returns a random element of the slice. An error will be returned if the slice has no elements in it.

func Float64

func Float64() (float64, error)

Float64 returns a random number in [0.0,1.0) as a float64.

func HexString

func HexString(size int) (string, error)

HexString returns a hexadecimal string of given length.

func Int63

func Int63() (int64, error)

Int64 returns a non-negative random 63-bit integer as a int64.

func Int63n added in v2.26.0

func Int63n(maxVal int64) (int64, error)

Int63n returns a non-negative integer in [0,maxVal) as an int64.

func Intn

func Intn(maxVal int) (int, error)

Intn returns a non-negative integer in [0,maxVal) as an int.

func Sha1String

func Sha1String() (string, error)

Sha1String returns a 40-character hexadecimal string, which matches the length of a SHA-1 hash (160 bits).

func String

func String(size int) (string, error)

String returns a random string using Default.

func StringCharset

func StringCharset(charSetStr string, size int) (string, error)

StringCharset generates a random string using the provided charset and size.

Types

This section is empty.

Jump to

Keyboard shortcuts

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