rng

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader will return a reader that will return an endless stream of pseudo-random data. The Reader supports seeking and arbitrary async reads from io.ReadAt.

func NewReader

func NewReader(opts ...ReaderOption) (*Reader, error)

NewReader returns a new Reader.

func (*Reader) Read

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

Read satisfies the io.Reader interface.

func (*Reader) ReadAt

func (r *Reader) ReadAt(p []byte, off int64) (n int, err error)

ReadAt satisfies the io.ReaderAt interface.

func (*Reader) Reset

func (r *Reader) Reset() error

Reset will reset the stream and scramble the seed.

func (*Reader) ResetSize

func (r *Reader) ResetSize(size int64) error

ResetSize will reset the stream and scramble the seed, as well as setting a new size.

func (*Reader) Seek

func (r *Reader) Seek(offset int64, whence int) (int64, error)

Seek provides stream seeking via io.Seeker interface. Streams without a size set cannot seek relative to end.

type ReaderOption

type ReaderOption func(options *readerOptions) error

ReaderOption provides an option to NewReader.

func WithFullReset

func WithFullReset(b bool) ReaderOption

WithFullReset will fully re-seed the reader on Reset. If set the entire stream will be randomized. If not set, it would be possible to derive a 32 byte xor value that makes it possible to predict a stream from the previous output.

func WithRNG

func WithRNG(rng io.Reader) ReaderOption

WithRNG allows to use a specific reader for entropy. Otherwise a math/rand prng with a seed based on current time will be added.

func WithSize

func WithSize(size int64) ReaderOption

WithSize limits the reader to a specific size.

Jump to

Keyboard shortcuts

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