ramazancetinkaya/obscura
最新稳定版本:1.0.0
Composer 安装命令:
composer require ramazancetinkaya/obscura
包简介
A multi-round polynomial-based encryption layer on top of AES-256 for enhanced security, without requiring GMP.
README 文档
README
Obscura is an advanced PHP cryptography library that combines robust AES encryption (AES-256-CBC by default) with a multi-round polynomial-based custom encryption layer for enhanced security. It also supports URL-safe Base64 encoding when desired.
Report a Bug · New Pull Request
No GMP extension needed – everything is done via the Extended Euclidean Algorithm for modular arithmetic.
Disclaimer: This code is presented for educational purposes. For production environments, ensure that you have conducted a thorough security review and implemented best practices for key management, tamper detection, and environment-specific compliance requirements.
⭐ Support the Project
If you find this library helpful, please consider giving it a star on GitHub. Your support helps improve and maintain the project. Thank you! 🌟
Table of Contents
Features
- AES-256-CBC: Provides a strong, battle-tested encryption foundation via OpenSSL.
- Multi-Round Custom Layer: Applies multiple polynomial transformations on each character, making cryptanalysis more challenging.
- No GMP Dependency: Uses the Extended Euclidean Algorithm for modular inverse, so GMP is not required.
- URL-Safe Base64 Option: Encrypt once, share anywhere. Prevents
+,/, and=characters from breaking URLs. - Strict Typing: Leverages PHP 8.0+ features and enforces strict typing for reliability.
- Custom Exceptions: Throws a
CryptoExceptionfor all encryption/decryption errors, making error handling straightforward.
Installation
You can install the Obscura library using Composer. Run the following command in your terminal:
composer require ramazancetinkaya/obscura
This command adds the library to your composer.json and installs it in the vendor/ directory.
Usage
Below are quick examples demonstrating how to use Obscura in your PHP project.
Basic Example
<?php require 'vendor/autoload.php'; use ramazancetinkaya\Obscura; use ramazancetinkaya\ObscuraException; try { // Create an Obscura instance $secretKey = 'my-super-secure-key'; $obscura = new Obscura($secretKey); // Data to encrypt $plainText = 'Hello World!'; // Encrypt $encrypted = $obscura->encrypt($plainText); echo "Encrypted (base64): " . $encrypted . PHP_EOL; // Decrypt $decrypted = $obscura->decrypt($encrypted); echo "Decrypted: " . $decrypted . PHP_EOL; } catch (ObscuraException $e) { echo "Error: " . $e->getMessage(); }
URL-safe Base64 Example
If you prefer URL-safe Base64 encoding (e.g. for inclusion in GET parameters), you can enable it via the constructor:
<?php require 'vendor/autoload.php'; use ramazancetinkaya\Obscura; use ramazancetinkaya\ObscuraException; try { // URL-safe Obscura instance $secretKey = 'my-super-secure-key'; $obscuraSafe = new Obscura($secretKey, 'aes-256-cbc', true); // Data to encrypt $plainUrl = 'https://example.com?param=someValue'; // Encrypt (URL-safe) $encryptedUrl = $obscuraSafe->encrypt($plainUrl); echo "Encrypted (URL-safe): " . $encryptedUrl . PHP_EOL; // Decrypt $decryptedUrl = $obscuraSafe->decrypt($encryptedUrl); echo "Decrypted URL: " . $decryptedUrl . PHP_EOL; } catch (ObscuraException $e) { echo "Error: " . $e->getMessage(); }
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
ramazancetinkaya/obscura 适用场景与选型建议
ramazancetinkaya/obscura 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 14, 最近一次更新时间为 2024 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cryptography」 「encryption」 「aes」 「decryption」 「polynomial」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ramazancetinkaya/obscura 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ramazancetinkaya/obscura 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ramazancetinkaya/obscura 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DUKPT implementation in PHP
A simple PHP class to encrypt a string and decrypt an encrypted string
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Encryption with AES-256 and HMAC-SHA256
Allows installation of Laravel where the PHP Mcrypt extension is not available. Provides encryption using OpenSSL, or by disabling encryption entierly.
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-28