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 link iconGenerate Tokenlink icon link iconand Get Alt IDlink icon 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 Keylink icon for testing environments.

Production

Download the Juspay Production Public Keylink icon for production environments.

Note

Please download the private key from the respective merchant’s dashboard. The private key is required to decrypt the encrypted API response generated by Juspay.

Merchant’s Dashboard
Merchant’s Dashboard


You can download the key from the following location in the merchant dashboard:

Path:
Settings → Security → RSA Keys

Last updated 13 days ago