random

package
v1.89.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package random contains a collection of utility functions to generate random numbers and strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rnd

type Rnd struct {
	// contains filtered or unexported fields
}

Rnd defines then random number generator.

func New

func New(r io.Reader) *Rnd

New initialize the random reader. The r argument must be a cryptographically secure random number generator. The crypto/rand.Read is used as default if r == nil.

func (*Rnd) RandUint32

func (r *Rnd) RandUint32() uint32

RandUint32 returns a pseudo-random 32-bit value as a uint32 from the default Source. It try to use crypto/rand.Reader, if it fails, it falls back to math/rand/v2.Uint32.

func (*Rnd) RandUint64

func (r *Rnd) RandUint64() uint64

RandUint64 returns a pseudo-random 64-bit value as a uint64 from the default Source. It try to use crypto/rand.Reader, if it fails, it falls back to math/rand/v2.Uint64.

func (*Rnd) RandomBytes

func (r *Rnd) RandomBytes(n int) ([]byte, error)

RandomBytes generates a slice of random bytes with the specified length.

Jump to

Keyboard shortcuts

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