<?php

$plaintext = '{"tid": "1840515U",
"amount": "10",
"organization_code": "Retail",
"additional_attribute1": "attribute1",
"additional_attribute2": "attribute2",
"additional_attribute3": "attribute3",
"invoiceNumber": "",
"rrn": "",
"type": "SALE",
"cb_amt": "",
"app_code": "", 
"tokenisedValue": "",
"actionId": "1",
"request_urn": ""
}';
$password = 'X5mUl3J1jneCd0adISoHWDTj7U8Rnhvd';
$method = 'aes-256-cbc';

// Must be exact 32 chars (256 bit)
$password = substr(hash('sha256', $password, true), 0, 32);
echo "Password:" . $password . "\n";

// IV must be exact 16 chars (128 bit)
//$iv = chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0) . chr(0x0);
$iv='1111111245683783';
// av3DYGLkwBsErphcyYp+imUW4QKs19hUnFyyYcXwURU=
$encrypted = base64_encode(openssl_encrypt($plaintext, $method, $password, OPENSSL_RAW_DATA, $iv));

// My secret message 1234
$decrypted = openssl_decrypt(base64_decode($encrypted), $method, $password, OPENSSL_RAW_DATA, $iv);

echo 'plaintext=' . $plaintext . "\n";
echo 'cipher=' . $method . "\n";
echo 'encrypted to: ' . $encrypted . "\n";
echo 'decrypted to: ' . $decrypted . "\n\n";

?>