inanepain/crypt
Composer 安装命令:
composer require inanepain/crypt
包简介
Encryption helpers and password hashers.
README 文档
README
Table of Contents
inanepain/crypt
Encryption helpers and password hashers.
1. Install
composercomposer require inanepain/crypt
2. Crypt
This is meant as more of an introduction to the classes found in the Inane\Crypt namespace and not an in-depth guide.
3. Secret
The Secret class is a helper for encrypting and decrypting strings using OpenSSL. It also provides methods to encode the encrypted data into a URL-safe format.
3.1. Properties
properties-
protected string $passphrase
-
protected string $cipher
-
protected ?string $iv
3.2. Methods
methods-
public function __construct(string $passphrase, string $cipher = 'aes-256-ctr', ?string $iv = null)
-
public function encrypt(string $plainText): string
-
public function decrypt(string $encryptedText): string
-
public function encode(string $encryptedText): string
-
public function decode(string $encodedText): string
-
public function encryptEncode(string $plainText): string
-
public function decryptDecode(string $encryptedEncodedText): string
3.2.1. Usage
To use the Secret class, you need to instantiate it with a passphrase (minimum 16 characters).
use Inane\Crypt\Secret; $passphrase = 'a-very-secret-phrase-of-at-least-16-chars'; $secret = new Secret($passphrase); $originalText = 'Hello World!'; // Encrypt $encrypted = $secret->encrypt($originalText); // Decrypt $decrypted = $secret->decrypt($encrypted); echo $decrypted; // Hello World!
3.2.2. URL Safe Encoding
Encrypted data often contains characters that are not safe for URLs (like +, /, =). The encode and decode methods handle this by replacing them with URL-safe alternatives.
$secret = new Secret($passphrase); $originalText = 'Sensitive Data'; // Encrypt and Encode in one go $urlSafeEncrypted = $secret->encryptEncode($originalText); // ... later ... // Decode and Decrypt $decrypted = $secret->decryptDecode($urlSafeEncrypted); echo $decrypted; // Sensitive Data
3.2.3. Custom Cipher and IV
By default, it uses aes-256-ctr. You can specify a different cipher or provide your own IV.
$secret = new Secret($passphrase, 'aes-128-cbc', 'my-custom-iv-123');
inanepain/crypt 适用场景与选型建议
inanepain/crypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「crypt」 「encrypt」 「decrypt」 「inane」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inanepain/crypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inanepain/crypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inanepain/crypt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Composer friendly version of http://web.archive.org/web/20130727034425/http://blog.kevburnsjr.com/php-unique-hash
Encrypted symfony entity's by verified and standardized libraries
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Strong cryptography tools and password hashing
This symfony user provider reads user from the htpasswd file.
Portable PHP password hashing framework
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: UNLICENSE
- 更新时间: 2026-04-15