saferand

package module
v0.0.0-...-960a4dd Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

README

saferand

Go Reference

A cryptographically secure implementation of math/rand or golang.org/x/exp/rand.

Documentation

Overview

Package saferand implements a cryptographically secure (mostly) drop-in replacement for exp/rand (and math/rand).

import rand "github.com/ericlagergren/saferand"

All Seed functions and methods are no-ops.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpFloat64

func ExpFloat64() float64

func Float32

func Float32() float32

func Float64

func Float64() float64

func Int

func Int() int

func Int31

func Int31() int32

func Int31n

func Int31n(n int32) int32

func Int63

func Int63() int64

func Int63n

func Int63n(n int64) int64

func Intn

func Intn(n int) int

func NewSource

func NewSource() exprand.Source

NewSource returns a cryptographically secure Source.

Unlike math/rand, the returned Source is safe for concurrent use by multiple goroutines.

func NormFloat64

func NormFloat64() float64

func Perm

func Perm(n int) []int

func Read

func Read(p []byte) (int, error)

func Seed

func Seed(_ uint64)

func Shuffle

func Shuffle(n int, swap func(i, j int))

func Uint32

func Uint32() uint32

func Uint64

func Uint64() uint64

Types

type ExpSource

type ExpSource struct{}

ExpSource implements Source.

func (ExpSource) Int63

func (ExpSource) Int63() int64

func (ExpSource) Seed

func (ExpSource) Seed(_ uint64)

func (ExpSource) Uint64

func (ExpSource) Uint64() uint64

type Rand

type Rand = exprand.Rand

func New

func New() *Rand

New returns a Rand that generated cryptographically secure random values.

type Source

type Source = exprand.Source

type Zipf

type Zipf = exprand.Zipf

func NewZipf

func NewZipf(r *Rand, s float64, v float64, imax uint64) *Zipf

Jump to

Keyboard shortcuts

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