Asymmetric
The /asymmetric endpoint performs RSA asymmetric key generation, encryption, and decryption.
curl -X POST \ "https://api.moxon.dev/v6/asymmetric" \ -H "Content-Type: application/json" \ -d '{}'Send the request to see the response here.
The request body must be JSON:
action"keygen" | "encrypt" | "decrypt"requiredAction to perform:
keygen,encrypt, ordecrypttextstringconditionalText to encrypt, or base64 ciphertext to decrypt
publicKeystringconditionalPEM public key (required for
encrypt)privateKeystringconditionalPEM private key (required for
decrypt)modulusLength"2048" | "4096"optionalRSA key size for
keygen:2048(default) or4096. Ignored forencrypt/decrypt— the size limit is derived from the actual keyalgorithm"rsa-oaep-sha256" | "rsa-oaep-sha1"optionalPadding algorithm:
rsa-oaep-sha256(default) orrsa-oaep-sha1
| Action | Description |
|---|---|
keygen | Generates an RSA key pair and returns both PEM-encoded public and private keys |
encrypt | Encrypts text with the public key using OAEP padding and returns the result as base64 |
decrypt | Decrypts a base64 ciphertext with the private key and returns the original plaintext |
OAEP padding reserves space inside each RSA block, so the maximum plaintext size depends on the key size and hash algorithm:
| Key Size | Algorithm | Max Plaintext |
|---|---|---|
| 2048 | rsa-oaep-sha256 | 190 bytes |
| 2048 | rsa-oaep-sha1 | 214 bytes |
| 4096 | rsa-oaep-sha256 | 446 bytes |
| 4096 | rsa-oaep-sha1 | 470 bytes |
The formula is: modulusLength / 8 − 2 × hashLength − 2.
keygen action:
actionstringkeygenalgorithmstringPadding algorithm used
modulusLengthnumberRSA key size in bits
publicKeystringPEM-encoded public key (SPKI)
privateKeystringPEM-encoded private key (PKCS#8)
encrypt / decrypt action:
actionstringAction performed (
encryptordecrypt)algorithmstringPadding algorithm used
resultstringBase64 ciphertext, or decrypted plaintext
If parameters are missing or invalid, the API will return an error:
- 400
Action must be "keygen", "encrypt", or "decrypt"Theactionvalue is not valid - 400
Unsupported algorithm. Use one of: rsa-oaep-sha256, rsa-oaep-sha1Thealgorithmvalue is not supported - 400
Modulus length must be 2048 or 4096ThemodulusLengthis not 2048 or 4096 - 400
Text is requiredThetextparameter is missing for encrypt - 400
Public key is requiredThepublicKeyis missing for encrypt - 400
Invalid public key formatThepublicKeydoes not start with the PEM header, or cannot be parsed as a valid key - 400
Text exceeds maximum length for this key size and algorithm (N bytes)The plaintext is too large for the key/algorithm - 400
Encryption failed: invalid key or data too largeThe encryption failed - 400
Encrypted data is requiredThetextparameter is missing for decrypt - 400
Private key is requiredTheprivateKeyis missing for decrypt - 400
Invalid private key formatTheprivateKeydoes not start with the PEM header - 400
Invalid key or corrupted dataThe decryption failed
Last updated on September 12, 2026