mjohann / simple-aes-256
Simple AES 256 is a PHP class designed to simplify encryption and decryption using AES-256 in CBC or GCM modes.
v1.1.0
2025-04-21 14:30 UTC
Requires
- php: ^8.0
README
SimpleAES256 is a PHP class designed to simplify encryption and decryption using AES-256 in CBC or GCM modes.
π¦ Installation
You can install the library via Packagist/Composer:
composer require mjohann/simple-aes-256
βοΈ Requirements
- PHP 8.0 or higher
π Features
- Supported AES 256 CBC and AES 256 GCM:
encrypt
decrypt
key
tag
π§ͺ Usage Example
Example AES 256 CBC
<?php use MJohann\Packlib\SimpleAES256; require_once "vendor/autoload.php"; $aes = new SimpleAES256("MyPassword"); $text = "My name is Matheus"; $encrypt = $aes->encrypt_cbc($text); $decrypt = $aes->decrypt_cbc($encrypt); echo "Simple AES 256 CBC", PHP_EOL; echo "Text: ", $text, PHP_EOL; echo "Encrypt: ", $encrypt, PHP_EOL; echo "Decrypt: ", $decrypt, PHP_EOL, PHP_EOL;
Example AES 256 GCM
<?php use MJohann\Packlib\SimpleAES256; require_once "vendor/autoload.php"; $aes = new SimpleAES256("MyPassword"); $text = "My name is Matheus"; $encrypt = $aes->encrypt_gcm($text); $tag = $aes->get_tag(); $decrypt = $aes->decrypt_gcm($encrypt, $tag); echo "Simple AES 256 GCM", PHP_EOL; echo "Text: ", $text, PHP_EOL; echo "Encrypt: ", $encrypt, PHP_EOL; echo "Tag: ", $tag, PHP_EOL, PHP_EOL; echo "Decrypt: ", $decrypt, PHP_EOL;
For more examples, see the example/script.php
file in the repository.
π Project Structure
simple-aes-256/
βββ src/
β βββ SimpleAES256.php
β βββ Facades/
β βββ SimpleAES256.php
βββ example/
β βββ script.php
βββ composer.json
βββ .gitignore
βββ LICENSE
βββ README.md
π License
This project is licensed under the MIT License. See the LICENSE file for more information.
π¨βπ» Author
Developed by Matheus Johann AraΓΊjo β Pernambuco, Brazil.