Skip to main content


We can generate use third party libraries to encrypt some data and use this library to decypher it.

OpenSSL command line

The OpenSSL command line can be used to encrypt some data. The command line is:

PASSWORD=$(openssl rand -hex 32)
IV=$(openssl rand -hex 16)
echo "this is a test" | openssl aes-256-cbc -e -a -K $PASSWORD -iv $IV

and then

$object = new OpenSSLCrypto($algorithm, \ByJG\Crypto\KeySet::generateKeySet());
echo $crypto->decryptWithKey(base64_decode($cypher), $key, $iv) . "\n";

JavaScript CryptoJS

The CryptoJS library can be used to encrypt some data. The code is:

<script src=""></script>
var myPassword = "myPassword";

// Can be obtained from KeySet::getKeyAndIv()
var key = "OgCSEZDInyGgQtnXMA9dNrwYd99UJh0L9kk/Q/sFX8g=";
var iv = "Ww4z5IE0Vcp9uYF5mvaqQA==";
var header = "xQUt";

var encrypted = CryptoJS.AES.encrypt(
iv: CryptoJS.enc.Base64.parse(iv),
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7

// This is the cypher to be used in PHP