secret command generates a cryptographically secure random key for encrypting paqet traffic.
Syntax
Description
This command generates a 32-byte (256-bit) cryptographically secure random key and prints it in hexadecimal format. The key is generated using Go’scrypto/rand package, which provides secure random number generation suitable for cryptographic purposes.
What It Generates
- Key Length: 32 bytes (256 bits)
- Format: Hexadecimal string (64 characters)
- Randomness: Cryptographically secure random bytes
Usage Example
Example Output
Where to Use the Key
Copy the generated key and paste it into yourconfig.yaml file under the transport.kcp.key field:
Generate a new key for each deployment or environment. Don’t reuse keys across different paqet installations.
Security Best Practices
- Generate a unique key for each client-server pair
- Store keys securely (use environment variables or secret management systems)
- Rotate keys periodically
- Never share keys over insecure channels
- Add
config.yamlto.gitignoreto prevent accidental commits
The key is used with the encryption algorithm specified in
transport.kcp.block (such as AES, Salsa20, or ChaCha20) to ensure both confidentiality and integrity of your traffic.