fixer112 / encrypter
Simple AES-256-CBC encrypter decrypter
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/fixer112/encrypter
Requires
- php: ^8.1
- illuminate/filesystem: ^12.0
- illuminate/support: ^12.0
- phpoption/phpoption: ^1.9
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- pestphp/pest: ^3.8
README
Simple AES-256-CBC encryption/decryption PHP library using fixed key and IV loaded from environment variables.
Installation
Install via Composer:
composer require fixer112/encrypter
Environment Setup
Create a .env file in your project root with these variables:
ENCRYPTER_KEY=your-secret-key-here ENCRYPTER_IV=your-iv-here
Usage
<?php require 'vendor/autoload.php'; use Fixer112\Encrypter\Encrypter; try { // Load .env (if not using Laravel, you need to load it manually) $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); $dotenv->load(); $encrypter = new Encrypter(); //or initiate key and iv //$key = $iv = "password"; //$encrypter = new Encrypter($key,$iv); $plaintext = "Hello, world!"; $encrypted = $encrypter->encrypt($plaintext); echo "Encrypted: " . $encrypted . PHP_EOL; $decrypted = $encrypter->decrypt($encrypted); echo "Decrypted: " . $decrypted . PHP_EOL; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Notes
- 
This package depends on your .env file to provide ENCRYPTER_KEY and ENCRYPTER_IV. 
- 
Make sure to keep your key and IV secret and do not commit them to public repositories.