Created
December 9, 2025 06:41
-
-
Save rkbi/62a39a48ffa94b9e8e7fe67804c07f83 to your computer and use it in GitHub Desktop.
Implementation of Encryption and Decryption function for SSLCommerz recurring API Payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function AppInfoEncryptUpDate($data = "", $key = "") | |
| { | |
| # Generate “iv”, a random value with standard of AES 256 CBC. | |
| $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length("aes-256-cbc")); | |
| # encrypt the plain data with a SALT Key which is predefined | |
| $encrypted = openssl_encrypt($data, "aes-256-cbc", $key, 0, $iv); | |
| # Add the iv with ciphertext by dividing the fixed value “|||” | |
| # Encode the complete text by base64 | |
| return base64_encode($iv . '|||' . $encrypted); | |
| } | |
| function AppInfoDecryptUpDate($data = "", $key = "") | |
| { | |
| # Decode the complete text by base64 | |
| # Divided the vi value based on ‘|||’ | |
| list($iv, $encrypted_data) = explode('|||', base64_decode($data), 2); | |
| // echo $iv . "<br>"; | |
| // echo $encrypted_data . "<br>"; | |
| # Decrypt the encrypted value by same predefined salt key | |
| return openssl_decrypt($encrypted_data, "aes-256-cbc", $key, 0, $iv); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment