cryptorand

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: AGPL-3.0 Imports: 4 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 Bool

func Bool() (bool, error)

Bool returns a random true/false value as a bool.

func Float32

func Float32() (float32, error)

Float32 returns a random number in [0.0,1.0) as a float32.

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 Int

func Int() (int, error)

Int returns a non-negative random integer as a int.

func Int31

func Int31() (int32, error)

Int31 returns a non-negative random 31-bit integer as a int32.

func Int31n

func Int31n(max int32) (int32, error)

Int31n returns a non-negative integer in [0,max) as a int32.

func Int63

func Int63() (int64, error)

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

func Int63n

func Int63n(max int64) (int64, error)

Int63n returns a non-negative random integer in [0,max) as a int64.

func Intn

func Intn(max int) (int, error)

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

func Uint32

func Uint32() (uint32, error)

Uint32 returns a 32-bit value as a uint32.

func Uint64

func Uint64() (uint64, error)

Uint64 returns a random 64-bit integer as a uint64.

func UnbiasedModulo32

func UnbiasedModulo32(v uint32, n int32) (int32, error)

UnbiasedModulo32 uniformly modulos v by n over a sufficiently large data set, regenerating v if necessary. n must be > 0. All input bits in v must be fully random, you cannot cast a random uint8/uint16 for input into this function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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