Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PseudorandomReader ¶
type PseudorandomReader struct {
// contains filtered or unexported fields
}
PseudorandomReader is a Reader providing seeded pseudorandom output from the keystream of an internal stream cipher.
It is not safe for concurrent use.
func NewReader ¶
func NewReader(seed []byte) *PseudorandomReader
NewReader initializes a PseudorandomReader by initializing its internal stream cipher.
type PseudorandomSource ¶
type PseudorandomSource struct {
// contains filtered or unexported fields
}
PseudorandomSource is a pseudorandom source implementing both rand.Source and rand.Source64, and can be used to initialize a rand.Rand.
Example ¶
// Create PseudorandomSource with a seed. Use a high entropy seed in most // real use cases. s := gopherng.NewSource([]byte{1, 2, 3, 4, 5}) // Create a rand.Rand from the Source. r := rand.New(s) fmt.Println(r.Float64()) // => 0.7124063346129034
Output:
func NewSource ¶
func NewSource(seed []byte) *PseudorandomSource
NewSource returns a new Source for the given seed. See NewReader() for seeding details.
func (*PseudorandomSource) Int63 ¶
func (s *PseudorandomSource) Int63() int64
Int63 returns an int64 from the internal PseudorandomReader.
func (*PseudorandomSource) Seed ¶
func (s *PseudorandomSource) Seed(seed int64)
Seed exists to be compatible with rand.Source, but is not implemented and will panic if called. It should not be needed for use with rand.Rand methods.
func (*PseudorandomSource) Uint64 ¶
func (s *PseudorandomSource) Uint64() uint64
Uint64 returns a uint64 from the internal PseudorandomReader.