Enkash Developer Portal
Home
Home
Login
  1. Home
  • Back to home
  • Prepaid Card APIs
  • Encryption & Decryption Guide
  • Auth Token
    POST
  • Create Card Account
    POST
  • Create Gift Card
    POST
  • Create Prepaid Card
    POST
  • Set Card PIN
    POST
  • Load Card Balance
    POST
  • Get Card Account Details
    POST
  • Generate Card OTP
    POST
  • View Card Details
    POST
  • Card Usage Controls
    POST
  • Get Card Usage Limits
    POST
  • Request Card Replacement
    POST
  • Block Card
    POST
  • Order Physical Card
    POST
  • Get Card Details
    POST
  • Get Transaction Details
    POST
  • Get All Transaction details
    POST
  1. Home

Encryption & Decryption Guide for EnKash API Integration

EnKash APIs require AES encryption with ECB mode and PKCS5 padding to secure request payloads. This guide walks you through implementing encryption and decryption in Java before sending and receiving API requests.

Encryption of API Requests #

To encrypt your request data before sending it to EnKash APIs, follow these steps:
1
Import Required Libraries
Add the following imports in your Java code:
2
Implement the Encryption Function
Create a method to encrypt request data using AES-128 with ECB mode and PKCS5 padding.
3
Generate a SecretKeySpec for Encryption
This method ensures the secret key is hashed and trimmed to 128 bits for AES encryption.
4
Encrypt Data Before Sending an API Request
Use the encryption method to secure your request data before passing it to the API.

Decryption of API Responses #

To decrypt the API response, implement the following
1
Decryption Function
2
Decrypt API Response
After receiving an encrypted API response, decrypt it using the following:
Do not include double quotes (" ") in input strings.
Ensure no trailing whitespaces exist in the encrypted string.
Use the same secret key for both encryption and decryption.
Always handle exceptions to avoid unexpected failures.
Modified at 2025-06-25 19:54:37
Next
Auth Token
Built with