randutil_kai

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2021 License: MIT Imports: 8 Imported by: 2

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

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.

func GenerateReaderCryptoRandomString

func GenerateReaderCryptoRandomString(n int, runes string, reader io.Reader) (string, error)

GenerateReaderCryptoRandomString generates a reader-based random string for cryptographic usage.

func ReaderCryptoUint64

func ReaderCryptoUint64(reader io.Reader) (uint64, error)

ReaderCryptoUint64 returns reader-based cryptographic random uint64.

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.

func NewReaderMathRandomGenerator

func NewReaderMathRandomGenerator(reader io.Reader) MathRandomGenerator

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

type ReaderMathRandomGenerator

type ReaderMathRandomGenerator 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.

Jump to

Keyboard shortcuts

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