/qrand

A Go quantum random number generating API using https://qrng.anu.edu.au with a fallback to crypto/rand.

Primary LanguageGoGNU General Public License v3.0GPL-3.0

qrand

import "qrand"

Package qrand provides true random numbers generated from the ANU Quantum Random Numbers Server, https://qrng.anu.edu.au, to which you must have connectivity for true randomness. Randomness from the quantum beyond!!! Fallback to Go's crypto/rand package in the event of no connectivity, but also return a PseudoRandomError.

Index

Variables

Attempts is the number of times to retry() the GET request if an error occurs.

var Attempts int = 2

The way their site's api works...

var ILength = 10 //Number of "packages" to receive
var ISize = 2 //Number of "items" in those packages

SleepTime is the time to wait between retry() attempts.

var SleepTime time.Duration = time.Second * 1

func Get

func Get(size int) (out []byte, err error)

func Get returns a quantum random []byte of size and a nil error, or a pseudo-random []byte of size and an error of type PseudoRandomError, or nil and a regular, old error.

PseudoRandomError is the error type returned if no complete interaction with the WebSite occurs and a pseudo-random []byte is returned instead. Check for it with "if _, ok := x.(qrand.PseudoRandomError); ok {..."

type PseudoRandomError struct{}

func (PseudoRandomError) Error

func (f PseudoRandomError) Error() string

type Reader

Reader is a drop-in, true random number generator replacement for crypto/rand's Reader.

type Reader struct{}

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Generated by gomarkdoc