dhrand

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2018 License: Apache-2.0 Imports: 5 Imported by: 1

README

dhrand

Build Status Code Coverage GoDoc Go Report Card GitHub Release Supported Go versions

dhrand is a Golang package that exports a LockedSource similar to golang.org/x/exp/rand

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenSeed

func GenSeed() (int64, error)

GenSeed generates a seed value using a cryptographically secure random number generator (CSRNG). Generated seed values should only be used to generate a truly random seed for a pseudo random number generator (PRNG), instead of using the program's initialization time. e.g. generated seed values do not make an arbitrary PRNG cryptographically secure.

Types

type LockedSource

type LockedSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LockedSource implements the rand.Source interface but is safe for usage with goroutines. Inspired by: golang.org/x/exp/rand

func NewLockedSource

func NewLockedSource(seed int64) *LockedSource

NewLockedSource creates a new LockedSource

func (*LockedSource) Int63

func (ls *LockedSource) Int63() int64

Int63 wraps the original source Int63 call in a mutex

func (*LockedSource) Seed

func (ls *LockedSource) Seed(seed int64)

Seed wraps the original source Seed call in a mutex

Jump to

Keyboard shortcuts

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