qrand

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: GPL-3.0 Imports: 8 Imported by: 1

README

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.

type PseudoRandomError

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

Documentation

Overview

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

Constants

This section is empty.

Variables

View Source
var Attempts int = 2

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

View Source
var ILength = 10 //Number of "packages" to receive

The way their site's api works...

View Source
var ISize = 2 //Number of "items" in those packages
View Source
var SleepTime time.Duration = time.Second * 1

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

Functions

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.

Types

type PseudoRandomError

type PseudoRandomError struct{}

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 {..."

func (PseudoRandomError) Error

func (f PseudoRandomError) Error() string

type Reader

type Reader struct{}

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

func (*Reader) Read

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

Jump to

Keyboard shortcuts

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