Card Data Encryption - Standalone Tokenization APIs
This script is used to encrypt card details and decrypt the API response using JWE encryption for standalone API testing. It is primarily used when calling APIs that require encrypted card data, such as Generate Token
and Get Alt ID
APIs.
Step 1: Card Data Preparation
Prepare your card payload in JSON format:
Step 2: Encrypt Card Data
Use the public key to encrypt the above payload. Here’s a simple Python script:
JWE Encryption / Decryption Script – Setup & Run GuideThis script encrypts and decrypts card payloads using JWE (JSON Web Encryption) with the RSA-OAEP-256 algorithm and A128GCM encryption.It uses the Python library jwcrypto.
Prerequisites:
Make sure the following are installed.
1.Python
Python 3.8+ recommended
Check version:
2.Install Required Library
Install jwcrypto:
3.Required Files
You need the following keys:
FilePurpose:Public Key (.pem):Used for encryption
Private Key (.pem)Used for decryption
4. Update Key Paths in Script
Update the Juspay public key path inside the encrypt function.
Replace:
recipient=loadPem('publickeyfilelocation')
with:
recipient=loadPem('/path/to/publicKey.pem')
Update the private key path inside the decrypt function.
Replace:
loadPem('privateKeylocation')
with:
loadPem('/path/to/privateKey.pem')
Step 3:Script:
Download Juspay Public Key
Use the following public keys to encrypt card details before sending requests to Juspay APIs.
Sandbox
Download the Juspay Sandbox Public Key for testing environments.
Production
Download the Juspay Production Public Key for production environments.
- Have questions?
- Need help? Contact support
- LLM? Read llms.txt

