定制 infocyph/epicrypt 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

infocyph/epicrypt

Composer 安装命令:

composer require infocyph/epicrypt

包简介

Modern cryptography, token, password and data-protection toolkit for PHP.

README 文档

README

Security & Standards Documentation Packagist Downloads License: MIT Packagist Version Packagist PHP Version GitHub Code Size

Epicrypt is a capability-first PHP security toolkit.

It provides focused security building blocks for:

  • Certificate / PKI / key exchange
  • Crypto primitives
  • Token security (JWT, payload, opaque)
  • Password and secret protection
  • Integrity verification
  • Secure generation
  • Data protection workflows
  • Security utilities (signed URL, CSRF, reset/action tokens)

Installation

composer require infocyph/epicrypt

Requirements

  • PHP >=8.4
  • ext-sodium, ext-openssl, ext-json, ext-mbstring, ext-hash

Usage Examples

Encrypt and decrypt a string

<?php

use Infocyph\Epicrypt\DataProtection\StringProtector;
use Infocyph\Epicrypt\Generate\KeyMaterial\KeyMaterialGenerator;

$key = (new KeyMaterialGenerator())->forSecretBox();
$protector = new StringProtector();

$ciphertext = $protector->encrypt('secret-value', $key);
$plaintext = $protector->decrypt($ciphertext, $key);

Encrypt and decrypt a file

<?php

use Infocyph\Epicrypt\DataProtection\FileProtector;
use Infocyph\Epicrypt\Generate\KeyMaterial\KeyMaterialGenerator;

$key = (new KeyMaterialGenerator())->forSecretStream();
$files = new FileProtector();

$files->encrypt('/data/plain.txt', '/data/plain.txt.epc', $key);
$files->decrypt('/data/plain.txt.epc', '/data/plain.out.txt', $key);

Rotate keys with a key ring

<?php

use Infocyph\Epicrypt\DataProtection\StringProtector;
use Infocyph\Epicrypt\Security\KeyRing;

$ring = new KeyRing([
    '2026-01' => $oldKey,
    '2026-05' => $newKey,
], '2026-05');

$protector = new StringProtector();
$ciphertext = $protector->encryptWithKeyRing('rotating-data', $ring);
$result = $protector->decryptWithKeyRingResult($ciphertext, $ring);

Hash, verify and rehash password

<?php

use Infocyph\Epicrypt\Password\PasswordHasher;

$hasher = new PasswordHasher();
$hash = $hasher->hashPassword('MyStrongPassword!2026');

$isValid = $hasher->verifyPassword('MyStrongPassword!2026', $hash);
$rehash = $hasher->verifyAndRehash('MyStrongPassword!2026', $hash);

Issue and verify CSRF token

<?php

use Infocyph\Epicrypt\Security\CsrfTokenManager;

$csrf = new CsrfTokenManager('csrf-secret');
$token = $csrf->issueToken('session-1');

$ok = $csrf->verifyToken('session-1', $token);

Generate and verify signed URL

<?php

use Infocyph\Epicrypt\Security\SignedUrl;

$signed = new SignedUrl('url-secret');
$url = $signed->generate('https://example.com/download', ['file' => 'report.pdf'], time() + 300);

$ok = $signed->verify($url);

Issue and verify JWT (HS512)

<?php

use Infocyph\Epicrypt\Token\Jwt\Enum\SymmetricJwtAlgorithm;
use Infocyph\Epicrypt\Token\Jwt\SymmetricJwt;
use Infocyph\Epicrypt\Token\Jwt\Validation\RegisteredClaims;

$issuer = new SymmetricJwt(SymmetricJwtAlgorithm::HS512);
$token = $issuer->encode([
    'iss' => 'issuer-service',
    'aud' => 'api',
    'sub' => 'user-1',
    'jti' => 'jwt-1',
    'nbf' => time(),
    'exp' => time() + 600,
], 'signing-secret');

$verifier = new SymmetricJwt(
    SymmetricJwtAlgorithm::HS512,
    new RegisteredClaims('issuer-service', 'api', 'user-1', 'jwt-1'),
);

$ok = $verifier->verify($token, 'signing-secret');

Generate certificate with SAN

<?php

use Infocyph\Epicrypt\Certificate\CertificateBuilder;
use Infocyph\Epicrypt\Certificate\CertificateOptions;
use Infocyph\Epicrypt\Certificate\Enum\OpenSslRsaBits;
use Infocyph\Epicrypt\Certificate\KeyPairGenerator;

$pair = KeyPairGenerator::openSsl(bits: OpenSslRsaBits::BITS_3072)->generate();
$dn = ['commonName' => 'service.example.test'];

$options = new CertificateOptions(
    sanDns: ['service.example.test', 'api.example.test'],
);

$certPem = CertificateBuilder::openSsl()->selfSign($dn, $pair['private'], options: $options);

Security

Protected by PHPForge — an automated quality and security gate for PHP projects.

Made with ❤️ for the PHP community
MIT Licensed
DocumentationSecurityCode of ConductContributingReport | Request | Suggest

infocyph/epicrypt 适用场景与选型建议

infocyph/epicrypt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 4, 最近一次更新时间为 2026 年 05 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 infocyph/epicrypt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 infocyph/epicrypt 我们能提供哪些服务?
定制开发 / 二次开发

基于 infocyph/epicrypt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 54
  • 依赖项目数: 0
  • 推荐数: 1

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-14