srand

package
v0.0.0-...-1480658 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

A thread safe cryptographically secure random number generator.

This is just a tiny wrapper around crypto/rand which:

  • performs buffering - rather than read from /dev/urandom for each random number request, it buffers entropy.
  • uses a thread safe pool - rather than locking and one global state, it maintains a buffer of entropy per thread pool.

If you run the included benchmark, you can see this is order of magnitudes faster than just using crypto/rand.

To use it, just create a new random number generator with it:

rng := rand.New(srand.Source)

Index

Constants

This section is empty.

Variables

View Source
var Source = &Generator{}

Functions

This section is empty.

Types

type Generator

type Generator struct{}

func (Generator) Int63

func (s Generator) Int63() int64

func (Generator) Seed

func (s Generator) Seed(seed int64)

func (Generator) Uint64

func (s Generator) Uint64() (v uint64)

Jump to

Keyboard shortcuts

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