randutil

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: MIT Imports: 6 Imported by: 154

README

randutil

Helper library for cryptographic and mathmatical randoms

Community

Pion has an active community on the Golang Slack. Sign up and join the #pion channel for discussions and support. You can also use Pion mailing list.

We are always looking to support your projects. Please reach out if you have something to build!

If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptoUint64 added in v0.1.0

func CryptoUint64() (uint64, error)

CryptoUint64 returns cryptographic random uint64.

func GenerateCryptoRandomString

func GenerateCryptoRandomString(n int, runes string) (string, error)

GenerateCryptoRandomString generates a random string for cryptographic usage.

Types

type MathRandomGenerator

type MathRandomGenerator interface {
	// Intn returns random integer within [0:n).
	Intn(n int) int

	// Uint32 returns random 32-bit unsigned integer.
	Uint32() uint32

	// Uint64 returns random 64-bit unsigned integer.
	Uint64() uint64

	// GenerateString returns ranom string using given set of runes.
	// It can be used for generating unique ID to avoid name collision.
	//
	// Caution: DO NOT use this for cryptographic usage.
	GenerateString(n int, runes string) string
}

MathRandomGenerator is a random generator for non-crypto usage.

func NewMathRandomGenerator

func NewMathRandomGenerator() MathRandomGenerator

NewMathRandomGenerator creates new mathmatical random generator. Random generator is seeded by crypto random.

Jump to

Keyboard shortcuts

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