Random Token Generator
Generate cryptographically secure opaque auth tokens, Bearer tokens, CSRF tokens, session IDs, and URL-safe verification tokens locally in your browser using the Web Crypto API.
High-entropy opaque bearer token safe for Authorization headers; store only its SHA-256 hash in your database.
In plain terms: a gaming PC guessing a million passwords per second would need 132,943,112,026,157,700,000,000,000,000,000,000 quintillion times the age of the universe. Even someone renting every cloud server on Earth — a trillion guesses per second — would need 132,943,112,026,157,700,000,000,000,000 quintillion times the age of the universe. Nobody is guessing this password; the only realistic risks are it being reused or phished.
Generated random tokens
Generate Cryptographic Tokens in Your Backend
Python stdlib URL-safe token (256 bits)
python3 -c "import secrets; print(secrets.token_urlsafe(32))"Node.js URL-safe token (256 bits)
node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"import { randomBytes, createHash, timingSafeEqual } from 'node:crypto'
export function issueOpaqueToken(prefix = 'tok_') {
const token = prefix + randomBytes(32).toString('base64url')
const tokenHash = createHash('sha256').update(token).digest('hex')
// Return `token` to the client ONCE; persist only `tokenHash` + expiresAt in DB
return { token, tokenHash }
}
export function verifyOpaqueToken(presented: string, storedHashHex: string): boolean {
const candidate = createHash('sha256').update(presented).digest()
const expected = Buffer.from(storedHashHex, 'hex')
return candidate.length === expected.length && timingSafeEqual(candidate, expected)
}Related Auth & Token Tools
Best practice: store a SHA-256 hash of every auth token
Treat opaque auth, bearer, and password-reset tokens like passwords in your database: show the raw token to the user once, and store SHA-256(token) server-side (high-entropy 256-bit random tokens do not need slow KDFs like bcrypt—fast SHA-256 lookup is safe and prevents database leaks from exposing active sessions).