isaac

package
v0.0.0-...-b6f29c3 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: ISC Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const MixMask = 0xFF << 2

MixMask is used to shave off the first 2 LSB from certain values during result generation

Variables

This section is empty.

Functions

This section is empty.

Types

type ISAAC

type ISAAC struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ISAAC The state representation of the ISAAC CSPRNG

func New

func New(key ...int) *ISAAC

New Returns a new ISAAC CSPRNG instance.

func New32

func New32(key ...uint32) *ISAAC

New Returns a new ISAAC CSPRNG instance.

func (*ISAAC) Float32

func (r *ISAAC) Float32() float32

func (*ISAAC) Float64

func (r *ISAAC) Float64() float64

func (*ISAAC) Int

func (r *ISAAC) Int() int

func (*ISAAC) Int31

func (r *ISAAC) Int31() int32

Int31 returns a pseudo-random 31-bit integer as an int32

func (*ISAAC) Int31n

func (r *ISAAC) Int31n(n int32) int32

Int31n Returns the next 4 bytes as a signed integer of 32 bits, with an upper bound of n from the ISAAC CSPRNG.

func (*ISAAC) Int63

func (r *ISAAC) Int63() (number int64)

Int63 Returns the next 8 bytes as a long integer from the ISAAC CSPRNG receiver instance.

func (*ISAAC) Int63n

func (r *ISAAC) Int63n(n int64) int64

Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). Returns -1 if provided upper-bound <= 0

func (*ISAAC) Intn

func (r *ISAAC) Intn(n int) int

Intn Returns the next 4 bytes as a signed integer of at least 32 bits, with an upper bound of n from the ISAAC CSPRNG.

func (*ISAAC) NextBytes

func (r *ISAAC) NextBytes(n int) []byte

NextBytes Returns the next `n` bytes from the ISAAC CSPRNG receiver instance, and since ISAAC generates 4-byte words,

if you request a length of bytes that is not divisible evenly by 4, it will stash the remaining bytes into a buffer
to be used on your next call to this function.

func (*ISAAC) NextChar

func (r *ISAAC) NextChar() byte

NextChar Returns the next ASCII character from the ISAAC CSPRNG receiver instance.

func (*ISAAC) Read

func (r *ISAAC) Read(dst []byte) (n int, err error)

func (*ISAAC) Seed

func (r *ISAAC) Seed(seed int64)

this will attempt to shake up the initial state a bit. Algorithm based off of Mersenne Twister's init Not sure if it's of any benefit at all, as ISAAC even when initialized to all zeros is non-uniform

func (*ISAAC) String

func (r *ISAAC) String(n int) (ret string)

String Returns the next `len` ASCII characters from the ISAAC CSPRNG receiver instance as a Go string.

func (*ISAAC) Uint16

func (r *ISAAC) Uint16() uint16

Uint16 Returns the next 2 bytes as a short integer from the ISAAC CSPRNG receiver instance.

func (*ISAAC) Uint32

func (r *ISAAC) Uint32() (number uint32)

Uint32 Returns the next 4 bytes as an integer from the ISAAC CSPRNG receiver instance. Guarenteed non-negative

func (*ISAAC) Uint64

func (r *ISAAC) Uint64() (number uint64)

Uint64 Returns the next 8 bytes as a long integer from the ISAAC CSPRNG receiver instance.

func (*ISAAC) Uint8

func (r *ISAAC) Uint8() byte

Uint8 Returns the next byte from the ISAAC CSPRNG receiver instance.

func (*ISAAC) Uint8n

func (r *ISAAC) Uint8n(bound byte) (number byte)

Uint8n Returns the next byte as an unsigned 8-bit integer, with an upper bound of n from the ISAAC CSPRNG.

Jump to

Keyboard shortcuts

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