fixer112/encrypter
最新稳定版本:v1.2.0
Composer 安装命令:
composer require fixer112/encrypter
包简介
Simple AES-256-CBC encrypter decrypter
README 文档
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.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03