nonce

package
v0.0.0-...-77bbea8 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package nonce implements a simple ASCII nonce generator, as well as some randomization utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCryptoRandSource

func NewCryptoRandSource() mathrand.Source64

NewCryptoRandSource returns a rand.Source64 backed by the cryptographically-secure random number generator in crypto/rand. If crypto/rand is unavailable, NewCryptoRandSource panics.

The returned rand.Source64 does not support seeding, and the Seed method is a no-op.

func RandomBase64

func RandomBase64(r *rand.Rand, n int) string

RandomBase64 returns a string of length n, consisting of random characters drawn from the provided rand.Rand. The output string will solely consist of base64url characters; that is, all alphanumerics with - and _ added.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator creates randomly generated ASCII nonces. The set of possible characters in generated nonces is the same as RandomBase64. A Generator instance is safe for concurrent use.

func NewGenerator

func NewGenerator(src rand.Source) *Generator

NewGenerator creates a new Generator from the given rand.Source.

func (*Generator) NewBase64

func (g *Generator) NewBase64(stateLen int) string

NewBase64 creates a new nonce with the given length.

Jump to

Keyboard shortcuts

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