Documentation ¶
Overview ¶
Package hashrand provides a random number source using hash functions.
Index ¶
- type Source
- func (s *Source) AppendSeed(b []byte)
- func (s *Source) Int63() int64
- func (s *Source) MarshalBinary() ([]byte, error)
- func (s *Source) Read(b []byte) (int, error)
- func (s *Source) Reset()
- func (s *Source) Seed(seed int64)
- func (s *Source) Uint64() uint64
- func (s *Source) UnmarshalBinary(b []byte) error
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 ¶
AppendSeed adds entropy to the current random seed. The new random seed will not take effect until the internal buffer is exhausted.
func (*Source) MarshalBinary ¶
MarshalBinary encodes the current state of s into a []byte. The result does not contain any information about the hash function.
func (*Source) Read ¶
Read implements io.Reader. Works identically to rand.Rand.Read unless multiple instances of rand.Rand use the same Source.
func (*Source) Seed ¶
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) UnmarshalBinary ¶
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.