Generate random API keys, secret keys, and access tokens. Create cryptographically secure random strings for authentication, encryption keys, and API access control.
Random key generation creates cryptographically secure random strings used for API authentication, encryption keys, session tokens, and access control. Using cryptographically secure randomness (crypto.getRandomValues in browsers) ensures keys are unpredictable and resistant to brute-force attacks.
Key = Base64(Hex(Random Bytes(length)))Random keys are generated by filling a buffer with cryptographically random bytes, then encoding them as hexadecimal or Base64 strings. The length determines the entropy: a 32-byte key has 256 bits of entropy, making brute force attacks computationally infeasible.
| Input | Output |
|---|---|
| Generate 32-byte hex key | a3f2c8e91b4d5a7f6e0c2d8b3a1f4e7d9c0b5a6e2d8f3c1b7a4e5d6f0c2a8b3 |
| Generate API key (prefix + random) | sk_live_4eC39HqLyjWDarjtT1zdp7dc |
| Generate 256-bit secret | 3j8K2mN5pR7tV9wX1yZ4aB6cD8eF0gH2iJ4kL6mN8oP0qR2sT4uV6wX8yZ0 |