Secret Key Generator
Generate secure random keys for your applications.
What Is a Secret Key?
A secret key is a cryptographically random string used to secure applications, sign tokens, encrypt data, and authenticate API requests. Unlike passwords (which humans type), secret keys are generated by algorithms and designed to be unpredictable, high-entropy strings that are virtually impossible to guess.
Common Use Cases
- JWT Signing: JSON Web Tokens use a secret key (HMAC) or private key (RSA) to sign and verify tokens. A strong secret prevents token forgery.
- API Authentication: Services issue API keys to identify and authorize callers. A random, long key prevents brute-force attacks.
- Session Secrets: Web frameworks (Express.js, Django, ASP.NET) use secret keys to sign session cookies and prevent tampering.
- Encryption Keys: AES encryption requires a key of specific length (128, 192, or 256 bits). This tool can generate hex keys of appropriate length.
- Webhook Signatures: Services like Stripe and GitHub sign webhook payloads with a secret so you can verify authenticity.
- CSRF Tokens: Anti-forgery tokens use random secrets to protect forms from cross-site request forgery.
How to Use
- Choose your desired key length (32–64 characters recommended for most uses).
- Click Generate to create a cryptographically secure random key.
- Click Copy to Clipboard and paste the key into your application config.
Best Practices
- Never commit secrets to version control. Use environment variables or a secrets manager.
- Use different keys per environment (development, staging, production).
- Rotate keys periodically and have a process to update them without downtime.
- Use sufficient length: At least 32 characters (256 bits) for HMAC-SHA256 signing.
Frequently Asked Questions
For HMAC-SHA256, use at least 32 bytes (64 hex characters). For AES-256, use exactly 32 bytes.
For general-purpose API keys, 32–64 characters provides excellent security.
Yes. Keys are generated using a cryptographically secure pseudorandom number generator (CSPRNG).
The output is not stored or logged on our servers.