Back to

Package random

Latest Go to latest

The latest major version is .

Published: May 5, 2020 | License: Apache-2.0 | Module:



const DefaultNonceSize = 16

type Noncer

type Noncer interface {
	Nonce() (string, error)

Noncer is a strategy for creating nonces for JWTs, to be stored in the jti claim.

func NewBase64Noncer

func NewBase64Noncer(random io.Reader, size int, encoding *base64.Encoding) Noncer

NewBase64Noncer creates a Noncer that generates a random sequence of bits encoded via the given base64 encoding. All parameters have defaults:

If random is nil, crypto/rand.Reader is used If size is nonpositive, DefaultNonceSize is used if encoding is nil, base64.RawURLEncoding is used

type RandomOut

type RandomOut struct {

	// Random is the source of randomness to use
	Random io.Reader

	// Noncer is the nonce generation strategy
	Noncer Noncer

RandomOut describes the components emitted by this package

func Provide

func Provide() RandomOut

Provide is an uber/fx provider that emits the components exposed by this package

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier