A free learning path on API keys and secrets: how to create, store, rotate and revoke them. No signup. Every lesson is on this page.
An API key is a shared secret. Anyone who holds it can call the API as you.
Generate keys with enough randomness, keep them out of git and out of browser code.
Least privilege, one key per service and environment, secrets managers and CI secrets.
The dual-key rotation pattern, rotation schedules, and the leak response order.
Short-lived tokens, workload identity federation and dynamic secrets.
Each module is a short checklist for a real project.
secrets module, in Node.js crypto.randomBytes, in the browser crypto.getRandomValues. Never use Math.random, timestamps or user IDs.sk_live_. A fixed prefix lets secret scanners, such as GitHub secret scanning, and people spot a leaked key..env in .gitignore and run a pre-commit scanner such as gitleaks or TruffleHog.pk_ keys, there and keep sk_ keys on the server.See the bits of entropy of a key format and the average time to guess it. It assumes a secure random generator.
Method: entropy = length × log2(character set size); average guesses = half the key space. The 112-bit minimum and 128-bit target follow the security strengths in NIST SP 800-57 Part 1. Educational tool, not a security audit.
Use at least 128 bits of randomness from a secure random generator. That is 16 random bytes, written as 32 hex characters or 22 base64url characters. Many providers use 32 bytes (256 bits).
There is no single rule. Rotate on a fixed schedule (the CIS AWS Foundations Benchmark flags access keys older than 90 days), and rotate at once after a suspected leak or when a person with access leaves.
Revoke or rotate the key at the provider first. Treat the key as already copied. Rewriting git history comes after, because forks, clones and caches keep the old commit.
They keep keys out of source code, but any process on the host and some crash reports can read them. For production, a secrets manager adds access control, audit logs and automatic rotation.