hashrand

package module
v0.0.0-...-608adc5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 8 Imported by: 0

README

hashrand

Maintainability Test Coverage CodeFactor Go Report Card GoDoc Build Status

Package hashrand provides a random number source using hash functions.

Documentation

Overview

Package hashrand provides a random number source using hash functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source struct {
	// Hash is the hash function used by this source. It should be treated
	// as immutable once the source has been used to generate random
	// numbers.
	//
	// If Hash is not explicitly set, it defaults to sha1.New().
	Hash hash.Hash
	// contains filtered or unexported fields
}

Source implements rand.Source and rand.Source64. Source is not safe for concurrent use by multiple goroutines.

func (*Source) AppendSeed

func (s *Source) AppendSeed(b []byte)

AppendSeed adds entropy to the current random seed. The new random seed will not take effect until the internal buffer is exhausted.

func (*Source) Int63

func (s *Source) Int63() int64

Int63 implements rand.Source.

func (*Source) MarshalBinary

func (s *Source) MarshalBinary() ([]byte, error)

MarshalBinary encodes the current state of s into a []byte. The result does not contain any information about the hash function.

func (*Source) Read

func (s *Source) Read(b []byte) (int, error)

Read implements io.Reader. Works identically to rand.Rand.Read unless multiple instances of rand.Rand use the same Source.

func (*Source) Reset

func (s *Source) Reset()

Reset clears the state of s.

func (*Source) Seed

func (s *Source) Seed(seed int64)

Seed implements rand.Source. It is equivalent to calling s.Reset followed by s.AppendSeed with the little-endian two's complement encoding of seed.

func (*Source) Uint64

func (s *Source) Uint64() uint64

Uint64 implements rand.Source64.

func (*Source) UnmarshalBinary

func (s *Source) UnmarshalBinary(b []byte) error

UnmarshalBinary resets the state of s to the state encoded in b. It does not assign a value to Hash, so Hash should be assigned manually before using this Source to generate any random numbers.

Jump to

Keyboard shortcuts

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