cryptorand

package
v2.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

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 Intn

func Intn(max int) (int, error)

Intn returns a non-negative integer in [0,max) 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