Elysia Tools

Browse tools, examples, visual explainers, and topic guides from one clear workspace.

Top Categories

Hubs

Language
ZHDERUPTENFRES

Elysia Tools

Navigation

Security

Nonce & Token Generator

· Last updated:2026-06-25

Generate cryptographically secure one-time tokens for web security scenarios — CSRF tokens, OAuth/OIDC state parameters, session nonces, and PKCE code_verifier/code_challenge (S256). Uses crypto.randomBytes, never Math.random.

Details

What this tool helps you do

This tool generates single-use high-entropy tokens for specific web-security scenarios. Unlike a generic random-string generator, each scenario applies the right conventions automatically.

Scenarios:

  • CSRF Token: an opaque token bound to a user session and submitted with state-changing requests (forms, AJAX) to prove the request came from your own page.
  • OAuth/OIDC State: an unguessable value sent to the authorization server and validated on the redirect callback, binding the response to this request and preventing login CSRF.
  • Session Nonce: a single-use random value tied to a session to prevent replay of a request.
  • PKCE Verifier + Challenge: generates a code_verifier (kept client-side) and derives the code_challenge = base64url(SHA256(verifier)) (sent to the auth server) per RFC 7636, so a leaked authorization code cannot be exchanged without the verifier. PKCE forces base64url encoding and a 32-96 byte verifier length (43-128 base64url chars).
  • Custom: a generic opaque high-entropy token for any single-use scenario you define; byte length is user-controlled (8-128).

Options:

  • Byte Length: bytes of entropy. Locked to 32 (256 bits) for all preset scenarios; user-editable (8-128) only in Custom.
  • Encoding: base64url (URL-safe, the default for web tokens), hex, or base64. Overridden to base64url for PKCE.
  • Add expiry timestamp prefix: prepends base36(expireAtSeconds).token so the server can reject expired tokens statelessly (OWASP-recommended pattern).
  • TTL (seconds): validity window used by the timestamp prefix.
  • Count: generate 1-50 tokens at once.

Security: randomness comes from Node's crypto.randomBytes(), the cryptographically secure source — never Math.random(). The PKCE challenge uses SHA-256 via crypto.createHash(). This tool generates token material only; it does not store or validate tokens server-side.

Execution

Run this tool

Fill in the form, run the tool, and review the result in one place.

Samples

Examples that match this tool

Related

Continue with connected tools and hubs

Written by the Elysia Tools team
Encryption40

Tool usage guide

Learn when to use this tool, what it supports, and how real users apply it.

Key facts

Category
Security
Input types
select, number, checkbox
Output type
html
Sample coverage
4
API ready
Yes

Overview

The Nonce & Token Generator provides cryptographically secure, high-entropy one-time tokens for critical web security workflows, including CSRF protection, OAuth/OIDC state validation, session nonces, and PKCE code verifiers and challenges. By utilizing Node's secure random bytes generator instead of insecure math functions, it ensures your tokens meet industry-standard security requirements with customizable encodings and optional stateless expiry prefixes.

When to use

  • When implementing OAuth 2.0 or OIDC authorization flows that require secure state parameters or PKCE code verifiers and challenges.
  • When securing web forms and API endpoints against Cross-Site Request Forgery (CSRF) using unique, session-bound tokens.
  • When generating single-use session nonces to prevent replay attacks or configuring Content Security Policy (CSP) headers.

How it works

  1. 1Select your target security scenario, such as CSRF, OAuth State, Session Nonce, or PKCE, to automatically apply standard byte lengths and encoding rules.
  2. 2Configure optional settings like custom byte lengths, output encoding (base64url, hex, or base64), and stateless expiry timestamp prefixes with a defined TTL.
  3. 3The tool generates high-entropy random bytes using a cryptographically secure source (crypto.randomBytes) and computes SHA-256 hashes for PKCE challenges.
  4. 4Copy the generated tokens, verifiers, or challenges directly into your application configuration or code.

Use cases

  • Generating PKCE code verifiers and S256 challenges for mobile or single-page application OAuth authorization requests.
  • Creating stateless, time-prefixed CSRF tokens to embed in HTML forms or AJAX request headers.
  • Generating secure state parameters to prevent login CSRF during OIDC federated authentication redirects.

Examples

1. Generate PKCE Verifier and Challenge for SPA Login

Frontend Developer

Background

A developer is setting up an Auth0 integration for a React single-page application and needs a valid PKCE code verifier and challenge pair to test the authorization code flow manually.

Problem

Manually generating a cryptographically secure verifier and hashing it with SHA-256 to produce a base64url-encoded challenge is complex to script quickly.

How to use

Select the 'PKCE Verifier+Challenge' scenario, keep the default 32-byte length and base64url encoding, and click generate.

{
  "scenario": "pkce",
  "byteLength": 32,
  "encoding": "base64url",
  "timestampPrefix": false,
  "count": 1
}

Outcome

The tool outputs a secure code_verifier string and its corresponding SHA-256 code_challenge, ready to be pasted into the OAuth authorization and token exchange requests.

2. Create Stateless CSRF Tokens with Expiry

Backend Engineer

Background

An engineer is implementing a stateless CSRF protection mechanism for an Express API and needs sample tokens with embedded expiration timestamps to test the validation middleware.

Problem

Generating tokens that contain a verifiable expiration time without setting up a database record requires precise timestamp prefixing.

FAQ

How does this tool generate random values?

It uses Node's cryptographically secure crypto.randomBytes() function, ensuring high entropy and unpredictability, rather than insecure pseudo-random generators like Math.random().

What is PKCE and how does the generator handle it?

Proof Key for Code Exchange (PKCE) prevents authorization code interception. The tool generates a secure code_verifier and derives the corresponding code_challenge using SHA-256 and base64url encoding.

What is the purpose of the expiry timestamp prefix?

It prepends a base36-encoded expiration timestamp to the token, allowing your server to validate token expiration statelessly without querying a database.

Why is base64url the default encoding?

Base64url is a URL-safe encoding that avoids characters like '+', '/', and '=', making it safe to pass in query parameters, headers, and cookies without URL encoding.

Are the generated tokens stored on your server?

No. The generation process runs entirely in your browser session, and no token data is stored, logged, or transmitted to any external server.

Hub

Authorized JWT, OTP, TOTP, and Session Test Workflow

Build sanitized auth fixtures, separate token generation from decoding and verification, test OTP/TOTP timing, and audit JWT and session evidence without exposing real secrets.

Home
Tools3212
Samples593
Visualizations471
Viewers103
Hubs239
Tags333
Images, Audio & Video657

Image, audio, and video processing, conversion, and optimization tools

Math, Date & Finance647

Calculators, numerics, date logic, statistics, and finance tools

Design & Color298

Color, layout, graphics, visual styling, and design helper tools

Text & Writing209

Writing, cleanup, formatting, extraction, and text analysis tools

Developer & Web193

Developer utilities, networking, web debugging, and automation helpers

Conversion & Encoding175

Format, file, archive, unit, and encoding conversion tools

Lead Generation Quiz Launch and Contact Handoff
Memorial Drafts: Family Review and Print Handoff
Private Habit Records: Backup, Restore and Sharing Review
Article to X and LinkedIn Drafts: Fact Review and Handoff
Markdown Interactive Deck Review and Offline Handoff

© 2026 Elysia Tools. All rights reserved.

DocsPricingAboutTerms of ServicePrivacy PolicyCookiesContact
Java

Android Image Processing Java Samples

Android Java image processing examples including reading/saving images, scaling, and format conversion

Kotlin

Android Image Processing Kotlin Samples

Android Kotlin image processing examples including reading/saving images, scaling, and format conversion

Python

Web Image Processing Python Samples

Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion

Rust

Web Image Processing Rust Samples

Web Rust image processing examples including image read/save, scaling, and format conversion

Media

Audio Read-Along Cue Generator

Generate sentence or word-level timestamp cues from a narration audio and its script, for karaoke-style reading and language learning.

Generator

Modern Unique ID Generator

Generate modern unique identifiers: ULID, NanoID, Snowflake and CUID2. Compare formats, decode ULID timestamps and pick the right ID for your system.

Security

AGEX Secure Share Note

Generate a plain-language share note for an AGEX bundle so recipients know how to decrypt and verify it safely

Security

Digital Signature Generator

Sign a message with a private key or verify a signature with a public key — supports RSA-PSS (SHA-256), ECDSA (P-256), and Ed25519. Pure client-side crypto (Node crypto.createSign/createVerify), no network. Paste a PEM key to sign or to verify a base64 signature. This tool signs/verifies; it does not generate key pairs.

How to use

Select the 'CSRF Token' scenario, enable 'Add expiry timestamp prefix', set the TTL to 600 seconds, and set the count to 5.

{
  "scenario": "csrf",
  "byteLength": 32,
  "encoding": "base64url",
  "timestampPrefix": true,
  "ttlSeconds": 600,
  "count": 5
}

Outcome

Generates 5 unique base64url-encoded tokens, each prefixed with a base36-encoded timestamp representing the expiration time 10 minutes in the future.