randutil

package
v0.32.16 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package randutil contains utilities for random numbers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewSeed

func MustNewSeed() (seed [32]byte)

MustNewSeed returns new 32-byte seed for pseudorandom generators.

Types

type LockedSource

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

LockedSource is an implementation of rand.Source that is concurrency-safe.

func NewLockedSource

func NewLockedSource(src rand.Source) (s *LockedSource)

NewLockedSource returns new properly initialized *LockedSource.

func (*LockedSource) Uint64

func (s *LockedSource) Uint64() (r uint64)

Uint64 implements the rand.Source interface for *LockedSource.

type Reader

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

Reader is a ChaCha8-based cryptographically strong random number reader that is safe for concurrent use.

func NewReader

func NewReader(seed [32]byte) (r *Reader)

NewReader returns a new properly initialized *Reader seeded with the given seed.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read generates len(p) random bytes and writes them into p. It always returns len(p) and a nil error. It's safe for concurrent use.

Jump to

Keyboard shortcuts

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