Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment token

crypto/random::token


Parameters

↳ var bytes: u64 = 32
↳ var encoding: string = "base64url"
↳ var name: string
↳ var plain_reveal: bool = false
↳ var transmission: string = "local"

Inputs

⇥ trigger: Block<void>

Outputs

↦ error: Block<string>
↦ failed: Block<void>
↦ token: Block<Secret<string>>


Generates a random token, as a secret.

Once trigger is received, bytes random bytes from the operating system are encoded with encoding (hex, base64, or base64url, without padding) into a token given through token, such as a password, a key for webhooks, or a token to give to a client. The secret is named name, and its policy is given by transmission (local, reference or value) and plain_reveal (whether the plain std/secret::reveal treatment may reveal it), as std/secret::conceal takes.

If bytes is not from 1 to 4096, or encoding or transmission is not valid, failed is emitted and error contains the reason.