Symmetric
The /symmetric endpoint encrypts and decrypts text using AES symmetric encryption.
curl -X POST \ "https://api.moxon.dev/v6/symmetric" \ -H "Content-Type: application/json" \ -d '{}'Send the request to see the response here.
The request body must be JSON:
action"encrypt" | "decrypt"requiredAction to perform:
encryptordecrypttextstringrequiredText to encrypt, or base64 blob to decrypt
keystringrequiredEncryption key (minimum 8 characters)
algorithm"aes-256-gcm" | "aes-256-cbc" | "aes-128-gcm"optionalCipher algorithm:
aes-256-gcm(default),aes-256-cbc, oraes-128-gcm
The raw key is never used directly. It is derived using scryptSync with a random 16-byte salt, producing a secure fixed-length key regardless of input length.
Encrypted output is returned as a base64 string with a binary layout that depends on the algorithm:
GCM: [16 bytes salt][12 bytes IV][16 bytes auth tag][ciphertext]
CBC: [16 bytes salt][16 bytes IV][32 bytes HMAC-SHA256 MAC][ciphertext]- Salt (16 bytes): used to derive the key (and, for CBC, a separate HMAC key)
- IV: initialization vector (12 bytes for GCM, 16 bytes for CBC)
- Auth tag / MAC: integrity verification — a native GCM tag (16 bytes) for GCM, or an HMAC-SHA256 MAC (32 bytes) for CBC, checked with a constant-time comparison
- Ciphertext: the encrypted content
Pass this blob as text to decrypt.
Breaking change in 5.4.0
CBC blobs now carry an integrity MAC. Blobs produced by aes-256-cbc before 5.4.0 (without a MAC) can no longer be decrypted — re-encrypt them with the current version. GCM blobs are unaffected.
actionstringAction performed (
encryptordecrypt)algorithmstringCipher algorithm used
resultstringEncrypted base64 blob, or decrypted plaintext
If parameters are missing or invalid, the API will return an error:
- 400
Action is requiredTheactionparameter is missing - 400
Action must be one of: encrypt, decryptTheactionvalue is not valid - 400
Text is requiredThetextparameter is missing or empty - 400
Text exceeds maximum allowed lengthThetextexceeds the maximum length - 400
Key is requiredThekeyparameter is missing - 400
Key must be at least 8 charactersThekeyis shorter than 8 characters - 400
Algorithm must be one of: aes-256-gcm, aes-256-cbc, aes-128-gcmThealgorithmvalue is not supported
Last updated on September 12, 2026