Download the PHP package lihongjie0209/sm-php-bc without Composer

On this page you can find all versions of the php package lihongjie0209/sm-php-bc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sm-php-bc

SM-PHP-BC

SM2/SM3/SM4 PHP 实现 - 基于 Bouncy Castle 架构

License: MIT PHP Version Composer

一比一复刻 Bouncy Castle Java 的 SM2、SM3 和 SM4 算法的 PHP 实现。

✨ 特性

密码算法

PKI 支持

其他特性

📦 安装

系统要求

🚀 快速开始

💡 提示: 以下是基础用法示例。想要完整的可运行代码?直接跳转到 📚 完整示例 章节,所有示例都可以直接运行!

以下代码片段展示了各算法的基本用法:

SM3 哈希

📖 完整示例: examples/sm3_demo.php

HMAC-SM3 消息认证码 🆕

📖 完整示例: examples/hmac_sm3_demo.php

SM2 密钥对生成

📖 完整示例: examples/sm2_demo.php

SM2 数字签名

📖 完整示例: examples/sm2_demo.php

SM2 公钥加密

📖 完整示例: examples/sm2_demo.php

SM4 对称加密

⚠️ 安全提示: 生产环境请使用 CBC、CTR 或 GCM 模式,避免使用 ECB 模式。

📖 完整示例:

SM2 密钥交换

💡 提示: SM2 密钥交换涉及多个参数类和步骤,建议查看完整示例了解详细用法。

📖 完整示例: examples/key_exchange_demo.php


📚 完整示例

所有算法都提供了完整的可运行示例,位于 examples 目录:

示例文件 说明 演示内容
sm3_demo.php SM3 哈希计算 基本哈希、分段更新、不同输入处理
hmac_sm3_demo.php 🆕 HMAC-SM3 认证 基础 HMAC、增量更新、API 签名
sm2_demo.php SM2 完整功能 密钥生成、签名验证、加密解密
sm2_pem_demo.php 🆕 SM2 PEM 编码 密钥导出/导入、文件存储
sm4_demo.php SM4 多种模式 ECB/CBC/CTR/CFB/OFB/GCM 模式
key_exchange_demo.php SM2 密钥交换 ECDH 协议、密钥协商
advanced_demo.php 高级特性 KDF、多种填充方案、复杂场景

🚀 运行示例

详细说明请查看 examples/README.md。

📖 文档

详细文档请查看 docs 目录:

🧪 测试

🔧 开发

📋 支持的算法

SM2(椭圆曲线密码)

SM3(哈希算法)

SM4(对称加密)

工作模式

填充方案

高级特性

🔐 安全建议

  1. 密钥管理:

    • 使用安全的随机数生成器生成密钥
    • 妥善保管私钥,不要硬编码在代码中
    • 定期更换密钥
  2. 工作模式选择:

    • 避免使用 ECB 模式(不安全)
    • 优先使用 GCM 模式(提供认证)
    • CBC/CTR 模式需配合 HMAC 使用
  3. IV 使用:

    • 每次加密使用不同的 IV
    • IV 可以公开,但必须不可预测
    • GCM 模式的 nonce 不能重复使用
  4. 填充选择:
    • PKCS7 是最常用的填充方案
    • 流模式(CTR/OFB/CFB)不需要填充
    • 注意填充 oracle 攻击

🤝 贡献

欢迎贡献代码!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建特性分支 (git checkout -b feature/amazing-feature)
  3. 提交更改 (git commit -m 'Add amazing feature')
  4. 推送到分支 (git push origin feature/amazing-feature)
  5. 创建 Pull Request

📄 许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

🙏 致谢

📮 联系方式

如有问题或建议,请通过以下方式联系:


注意: 本实现仅供学习和研究使用。如需在生产环境中使用国密算法,请确保符合相关法律法规要求,并进行充分的安全评估和测试。


All versions of sm-php-bc with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-gmp Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package lihongjie0209/sm-php-bc contains the following files

Loading the files please wait ...