oyedele/crypto-helper
最新稳定版本:v1.0.0
Composer 安装命令:
composer require oyedele/crypto-helper
包简介
This is a Laravel/PHP helper function for encryption and decryption of data using OPENSSL
README 文档
README
A lightweight PHP/Laravel package for handling encryption and decryption with OpenSSL. Supports both Laravel integration (via Service Provider & config publishing) and standalone PHP usage.
Installation
1. Require the package via Composer
composer require oyedele/crypto-helper
2. (Laravel Only) Register the Service Provider
If you are using Laravel 5.5+, the service provider is auto-discovered.
For older versions, add the following to config/app.php:
'providers' => [ // ... Oyedele\CryptoHelper\CryptoHelperServiceProvider::class, ];
3. (Laravel Only) Publish the Config
php artisan vendor:publish --tag=config
This will create a file at:
config/crypto-helper.php
Default config:
return [ 'cipher' => 'AES-128-ECB', 'options' => OPENSSL_RAW_DATA, ];
⚡ Usage
Laravel Example
use Oyedele\CryptoHelper\CryptoHelper; // Encrypt $encrypted = CryptoHelper::encrypt('my-secret-data', 'my-secret-key'); // Decrypt $decrypted = CryptoHelper::decrypt($encrypted, 'my-secret-key'); echo $decrypted; // "my-secret-data"
You can also set the default key in config/crypto-helper.php or at runtime:
config(['crypto-helper.key' => 'my-default-key']); $encrypted = CryptoHelper::encrypt('data'); // uses default key
Standalone PHP Example
When using outside Laravel, configuration falls back to the built-in Config class.
require 'vendor/autoload.php'; use Oyedele\CryptoHelper\Config; use Oyedele\CryptoHelper\CryptoHelper; // Set encryption key globally Config::set('key', 'my-standalone-key'); // Encrypt $encrypted = CryptoHelper::encrypt('standalone-data'); // Decrypt $decrypted = CryptoHelper::decrypt($encrypted); echo $decrypted; // "standalone-data"
Configuration Options
| Key | Description | Default |
|---|---|---|
cipher |
OpenSSL cipher algorithm | AES-128-ECB |
options |
OpenSSL options (e.g., OPENSSL_RAW_DATA) |
OPENSSL_RAW_DATA |
key |
Encryption key (set manually or via config) | null |
Testing
Run PHPUnit tests:
vendor/bin/phpunit
Package Structure
crypto-helper/
├── config/
│ └── crypto-helper.php # Default config
├── src/
│ ├── Config.php # Standalone config manager
│ ├── CryptoHelper.php # Core encryption/decryption
│ └── CryptoHelperServiceProvider.php # Laravel provider
├── tests/
│ └── CryptoHelperTest.php # PHPUnit tests
└── README.md
License
This package is open-sourced software licensed under the MIT license.
oyedele/crypto-helper 适用场景与选型建议
oyedele/crypto-helper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 223 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 oyedele/crypto-helper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oyedele/crypto-helper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 223
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-09