🔐 Secure Token Generator – Cryptographically Safe Keys & Secrets
The Secure Token Generator is a browser-based tool for generating cryptographically secure random tokens, API keys, passwords, UUIDs, nonces, and short unique IDs. All randomness is sourced from window.crypto.getRandomValues() — the browser's native Web Cryptography API — ensuring your tokens are unpredictable and suitable for security-sensitive applications.
Unlike tokens produced by Math.random(), which is a pseudorandom number generator unsuitable for security, this tool produces tokens that are cryptographically indistinguishable from truly random data.
🛡️ Supported Token Modes
Choose from seven generation modes, each tailored to a specific use case:
- API Key / Secret Token — A hex- or base64-encoded random byte sequence, ideal for API authentication, OAuth client secrets, and service credentials.
- UUID v4 — A standards-compliant RFC 4122 random UUID with 122 bits of entropy, used as database primary keys, correlation IDs, and resource identifiers.
- UUID v7 — A time-ordered UUID per RFC 9562, embedding a 48-bit Unix timestamp in the high bits. Ideal for database keys that must sort chronologically.
- Secure Password — A configurable character-set password with upper/lowercase, digits, and symbols, with an option to exclude ambiguous characters (0/O, 1/l/I) for better readability.
- Base64 URL-safe Token — A compact, URL-embeddable token suitable for cookies, OAuth state parameters, and email verification links.
- Nonce / Salt / IV — Fixed-size random values for cryptographic operations: AES initialization vectors (16 bytes), HMAC salts, and challenge-response nonces.
- NanoID / Short ID — URL-friendly unique identifiers using a URL-safe alphabet (A–Z, a–z, 0–9, -, _), similar to the popular nanoid library.
📐 Understanding Entropy
Entropy measures the unpredictability of a token in bits. The formula for character-based tokens is:
Entropy (bits) = log₂(alphabet size) × token lengthFor byte-based tokens (API keys, nonces), each byte contributes 8 bits of entropy. Common reference points:
- UUID v4: 122 bits of randomness (6 bits are fixed for version and variant)
- 32-byte hex token: 256 bits — rated Excellent
- 20-char alphanumeric+symbol password: ~131 bits — rated Strong
⚙️ Output Encodings Explained
The same random bytes can be represented in several encodings, each with different trade-offs:
- Hex — Uses characters
0–9anda–f. Output is exactly 2× the byte count. Easy to read and compare; safe in all contexts. - Base64 — Uses
A–Z,a–z,0–9,+,/. Approximately 1.33× the byte count. Compact but contains characters that need escaping in URLs. - Base64 URL-safe — Replaces
+with-and/with_, omits padding. Safe in URL query strings, HTTP headers, and cookies without encoding. - Binary — Raw bit representation as space-separated 8-bit groups. Useful for educational purposes and low-level debugging.
🔑 Common Use Cases & Recommended Settings
Here are recommended configurations for typical developer scenarios:
- API Key: Mode = API Key, 32 bytes, Hex or Base64 URL-safe → 256 bits entropy (Excellent)
- Session Token / CSRF Token: Mode = API Key, 16–32 bytes, Base64 URL-safe → 128–256 bits
- Database Primary Key: Mode = UUID v4 (random) or UUID v7 (time-sortable)
- Human-readable Password: Mode = Secure Password, 20 chars, Alphanumeric+Symbols, Exclude Ambiguous → ~131 bits
- AES-256 IV: Mode = Nonce/IV, 16 bytes, Hex
- Short URL ID: Mode = NanoID, 21 characters → ~126 bits
- Webhook Secret: Mode = API Key, 32 bytes, Hex, Prefix =
whsec_
🔒 Privacy & Security
This tool operates 100% client-side. No tokens, inputs, or configuration data are ever transmitted to any server. Your generated secrets stay on your device. The tool does not use cookies, analytics, or any form of persistent storage for your generated values.
Always store generated secrets securely — never commit them to version control, embed them in client-side JavaScript, or log them in plaintext. For server-side storage, use a secrets manager or store a hashed version (e.g., HMAC-SHA256) of the token.