Encryption & Decryption Guide
Encryption & Decryption Guide for EnKash API Integration
Encryption of API Requests
Import Required Libraries
Add the following imports in your Java code:
Implement the Encryption Function
Create a method to encrypt request data using AES-128 with ECB mode and PKCS5 padding.
Generate a SecretKeySpec for Encryption
This method ensures the secret key is hashed and trimmed to 128 bits for AES encryption.
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
Decryption Function
Decrypt API Response
After receiving an encrypted API response, decrypt it using the following:
" "
) 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-03-02 18:42:11