Secure Token Generator

Generate secure random tokens, API keys, session tokens, and cryptographic nonces for applications

Quick Presets

Configuration

Character sets: A-Z, a-z, 0-9

Active Result

Cryptographically secure tokens • Updates in real-time

Configure your settings to generate secure tokens

Security Best Practices

• Use minimum 32 characters for API keys
• Include symbols for maximum entropy
• Rotate tokens regularly based on usage
• Store tokens encrypted, never in plain text
• Use HTTPS for all token transmissions
• Implement proper token expiration policies

Entropy Levels

256+ bits:Excellent (Military-grade)
128+ bits:Very Strong (Crypto standard)
80+ bits:Strong (Good for most apps)
64+ bits:Moderate (Basic security)
<64 bits:Weak (Avoid for security)

Token Usage Guidelines

  • API Keys: 64+ characters, alphanumeric only for better compatibility
  • Session Tokens: 32+ characters, set proper expiration times
  • CSRF Tokens: 32+ characters, unique per user session
  • Recovery Codes: Shorter (16 chars) but human-readable format
  • Ultra Secure: 128+ characters with symbols for maximum protection

About Secure Token Generation

Secure tokens are cryptographically random strings used for authentication, authorization, session management, and security purposes. They provide unpredictable values that are computationally infeasible to guess or reproduce, making them essential for secure applications and systems.

  • Cryptographically secure random number generation (CSPRNG)
  • API keys and authentication tokens for secure access control
  • Session tokens for user authentication and state management
  • CSRF tokens for cross-site request forgery protection
  • Nonces for cryptographic operations and replay attack prevention

Token Types and Applications

Authentication Tokens

  • API Keys: Long-term access credentials for services
  • Bearer Tokens: OAuth 2.0 access tokens
  • Session Tokens: Temporary user authentication
  • Refresh Tokens: Renew expired access tokens
  • JWT Secrets: Signing keys for JSON Web Tokens
  • CSRF Tokens: Protection against cross-site attacks

Cryptographic Tokens

  • Nonces: Number used once in crypto protocols
  • Salt Values: Random data for password hashing
  • Initialization Vectors: Random seeds for encryption
  • Challenge Codes: Random values for auth challenges
  • Recovery Codes: Backup authentication methods
  • Device IDs: Unique device identification

Frequently Asked Questions

How to generate secure random tokens?

Use a CSPRNG like crypto.getRandomValues() in browsers or crypto.randomBytes() in Node.js. Select your desired length and encoding (hex, base64, alphanumeric), then generate. utilAZ does this client-side via the Web Crypto API so the token never leaves your device.

What is a cryptographically secure random number generator?

A CSPRNG produces output that is computationally indistinguishable from true randomness. It seeds from OS-level entropy sources (hardware interrupts, thermal noise) and ensures no observer can predict future output from past values. Examples include /dev/urandom, CryptGenRandom, and the Web Crypto API.

How many bits for a secure API key?

Use at least 128 bits (16 bytes) of entropy for general tokens and 256 bits (32 bytes) for high-security API keys. When encoded as hex this becomes 32 or 64 characters respectively. Base64 encoding is more compact: 22 or 43 characters for the same entropy.

Difference between UUID and random token?

UUIDs (v4) contain 122 random bits in a fixed 36-character format with dashes. Random tokens can be any length and encoding, offering more flexibility. For pure security use cases, a raw 256-bit random token is stronger and more compact than a UUID.

Is nanoid cryptographically secure?

Yes, nanoid uses crypto.getRandomValues() internally, making it cryptographically secure. It also avoids modulo bias by using a bitmask rejection method. Its default 21-character alphabet gives about 126 bits of entropy, comparable to UUIDv4.

How to generate JWT tokens with HMAC?

Create a header ({alg: HS256, typ: JWT}) and payload, Base64URL-encode both, concatenate with a dot, then sign using HMAC-SHA256 with your secret key. The final token is header.payload.signature. Use a 256-bit random secret for HS256 signing.

Token Security Best Practices

Generation Guidelines:

Entropy Requirements
• Minimum 128 bits of entropy
• Use cryptographically secure RNG
• Avoid predictable patterns
Character Sets
• Base64: URL-safe encoding
• Hex: Lowercase hexadecimal
• Alphanumeric: Case-sensitive mix
Length Recommendations
• API Keys: 32-64 characters
• Session: 32-43 characters
• CSRF: 32 characters minimum

Management Practices:

Storage Security
• Encrypt tokens at rest
• Hash for database storage
• Secure key management
Transmission Security
• HTTPS/TLS only
• Secure HTTP headers
• Avoid URL parameters
Lifecycle Management
• Regular token rotation
• Proper expiration times
• Revocation capabilities

How Token Generation Works

Secure token generation relies on cryptographically secure pseudo-random number generators (CSPRNGs) to produce unpredictable output. Modern browsers provide the crypto.getRandomValues() API, while Node.js offers crypto.randomBytes(), both sourced from operating system entropy pools.

Quick Example (Browser & Node.js)

// Browser: generate a 32-byte hex token
const bytes = crypto.getRandomValues(new Uint8Array(32));
const token = Array.from(bytes, b => b.toString(16).padStart(2, '0')).join('');

// Node.js equivalent
const { randomBytes } = require('crypto');
const token = randomBytes(32).toString('hex');

The tool above uses the same underlying CSPRNG APIs and lets you choose output format (hex, base64, base64url, or alphanumeric), token length, and optional prefixes, eliminating the need to write boilerplate code for each project.

Token Formats and Examples

Format Examples:

Hex: a1b2c3d4e5f67890abcdef
Base64: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Base64URL: QWxhZGRpbjpvcGVuIHNlc2FtZQ
Alphanumeric: Kj8bN3mZ9qR2vX4wE7sT
API Key: sk_1Hd8K3jF9qR2vX4wE7sT9mZ
Session: sess_AbC123XyZ789

Security Levels:

256+ bits: Military grade security
128-255 bits: Cryptographically secure
80-127 bits: Good for most apps
64-79 bits: Moderate security
40-63 bits: Weak protection
<40 bits: Easily crackable

Token Lifecycle Management

  • Generation: Use cryptographically secure random number generators
  • Distribution: Transmit tokens over secure channels (HTTPS/TLS only)
  • Storage: Encrypt tokens at rest, use secure storage mechanisms
  • Usage: Implement proper authentication and authorization checks
  • Rotation: Regular token renewal based on security policies
  • Revocation: Immediate invalidation when compromise is suspected
  • Monitoring: Log access patterns and detect anomalies
  • Expiration: Set appropriate time limits for token validity

Common Use Cases

  • REST API authentication and authorization
  • Session management for web applications
  • CSRF protection tokens
  • OAuth 2.0 access and refresh tokens
  • JWT signing secrets
  • Database connection strings
  • Webhook verification tokens
  • Device registration and identification