Developer Jun 24, 2026

Why the Same Random Token Breaks in Some Contexts — Hex vs Base64url vs Standard Base64 Explained

URL-safe Base64, hex, and standard Base64 are different representations of the same randomness — and the wrong choice causes "invalid token" errors when + and / characters in standard Base64 get interpreted as spaces and path separators in URLs. Here's a decision table for token format by context, why prefixed tokens (sk_live_, ghp_) enable security scanner detection of committed secrets, and why you should store only the SHA-256 hash of tokens, never the raw token.

Developer Jun 21, 2026

Random Strings for Test Data vs Security Tokens: The Difference That's Invisible in the Output

Generating a random string and generating a *secure* random string can look identical — but only one is safe as a session token or API key. Here's how CSPRNGs differ from standard PRNGs (Mersenne Twister can be fully reconstructed from 624 outputs), how alphabet choice affects entropy per character, why test data often needs structured fake data rather than random strings, and why "always use a CSPRNG" is often the simplest safe policy.

Developer Jun 13, 2026

UUID v4 vs UUID v7 vs ULID vs NanoID: Which Identifier Format Should You Use?

UUID v4's random bits fragment database B-tree indexes, causing write amplification. UUID v7 adds a millisecond timestamp prefix to fix this. ULID is sortable and URL-safe without hyphens. NanoID is compact and customisable. Here's how each works and when to choose each format.

Developer Jun 9, 2026

Secure Randomness: Why Math.random() Fails for Security Tokens — and the Right Alternatives

Math.random() in JavaScript is predictable from 128 observations. Python's random module explicitly warns it's not for security. Here's why PRNGs fail for tokens, the secure alternatives in every major language, and the specific bit lengths needed for different security contexts.

Developer Jun 8, 2026

How Long Does a Random String Need to Be? The Birthday Problem Explained

How long does a random string need to be? The birthday problem shows that 6-character codes collide far sooner than most developers expect. Here's how to calculate the right length for tokens, IDs, and API keys.

Developer Jun 6, 2026

Random String Generator — Secure Tokens, API Keys & Test Data

Learn when and how to generate random strings for session tokens, API keys, OTPs, and test data — what character sets to use, how long they should be, and what entropy actually means in practice.