gabbro-php/crypt
Composer 安装命令:
composer require gabbro-php/crypt
包简介
Encryption and Hash library
README 文档
README
This library provides a unified abstraction layer for message digests and symmetric ciphers, built around two core interfaces:
Digest— for hashing, HMACs, verification, and key derivation.Cipher— for symmetric encryption and decryption.
It includes implementations backed by both PHP’s native extensions (hash, OpenSSL) and libsodium, so you can pick the provider that best fits your environment.
✨ Features
Digest
- Unified interface for:
- Hashing arbitrary data
- Creating and verifying MACs
- Deriving keys from global secrets + salt
- Configurable “levels” for computational cost:
- Fast (low iterations)
- Moderate (default for most apps)
- Sensitive (high security, slow, suitable for offline tasks)
- Implementations:
- HashDigest: Uses PHP’s
hash_*andhash_pbkdf2 - SodiumDigest: Uses libsodium’s
crypto_pwhash,crypto_generichash, andcrypto_auth
- HashDigest: Uses PHP’s
Cipher
- Unified interface for symmetric encryption/decryption
- Implementations:
- SSLCipher: Wraps OpenSSL, supporting AES, Camellia, Aria, and many other algorithms/modes.
- SodiumCipher: Wraps libsodium’s
crypto_secretbox, providing authenticated encryption (confidentiality + integrity in one step).
- Automatic key and IV/nonce management, with helpers for generation and normalization.
🔑 Security Model
- OpenSSL ciphers: require explicit IVs and may require separate HMACs for authenticity (unless using AEAD modes like GCM).
- Sodium ciphers: always use authenticated encryption (via XSalsa20 + Poly1305). Any tampering with ciphertext is detected during decryption.
This library ensures correct handling of secrets, salts, IVs, and nonces to reduce cryptographic misuse.
📦 Requirements
- OpenSSL extension (for
SSLCipher) - Libsodium extension (for
SodiumCipher/SodiumDigest)
🔐 Philosophy
The main goal is to make crypto easy to use correctly:
- Configure once (secret, salt, key size, cipher mode).
- Use everywhere without boilerplate.
- Provide safe defaults and abstract away low-level details.
gabbro-php/crypt 适用场景与选型建议
gabbro-php/crypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gabbro-php/crypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gabbro-php/crypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-27