The crypt package creates a simple interface for the phpseclib AES-128 library. Its interface allows encryption and decryption of strings with a layer of base64 encoding for easy transmission including the initialization vector.
composer require crowdstar/crypt:~1.0.0
<?php
use CrowdStar\Crypt\Crypt;
$encodedEncryptedData = (new Crypt("secret_key"))->encrypt("message");
<?php
use CrowdStar\Crypt\Crypt;
$encodedEncryptedData = (new Crypt("secret_key"))->decrypt("encoded_encrypted_data");
<?php
use CrowdStar\Crypt\Crypt;
$crypt = new Crypt("secret_key");
$alternateIVLength = 8;
$encodedEncryptedData = $crypt->encrypt("message", $alternateIVLength);
$plainText = $crypt->decrypt($encodedEncryptedData, $alternateIVLength);