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

This package is auto-updated.

Last update: 2025-04-21 14:40:19 UTC


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.