Steps to Encrypt Payload
- Obtain the RSA public key from your dashboard (Base64 encoded)
- Convert the public key from Base64 into an RSA PublicKey object
- Initialize an RSA cipher using OAEP with SHA-256 padding
- Encrypt the plaintext payload (e.g., password) using UTF-8 encoding
- Base64-encode the encrypted output
- Send the encrypted value in your API request payload
Code Examples
Java
JavaScript (Node.js)
Python
pip install cryptography
C# (.NET)
API Request Example
Once you have the encrypted value, include it in your API request:Important Notes
- Payload Size Limit: RSA encryption has a maximum payload size based on key length. For a 2048-bit key, the maximum is approximately 190 bytes. Only encrypt individual sensitive fields, not entire request bodies.
- Public Key Only: Never share your private key. Only the public key should be used for encryption on your side.
- Key Rotation: When you rotate your keys on the dashboard, update your integration with the new public key immediately.
- Encoding: Always use UTF-8 encoding for the plaintext before encryption.
- Transport Security: While encryption protects the data in the payload, always use HTTPS for all API communications.
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Decryption fails | Wrong key used | Verify you’re using the current public key from dashboard |
| Padding error | Incorrect cipher mode | Ensure using OAEPWithSHA-256AndMGF1Padding |
| Key format error | Base64 decode issue | Check for line breaks or spaces in the key |
| Size limit exceeded | Payload too large | Only encrypt individual fields, not entire bodies |
