soatok/minisign
Composer 安装命令:
composer require soatok/minisign
包简介
PHP implementation of minisign, based on libsodium
README 文档
README
PHP implementation of Minisign. Powered by Libsodium.
Installing
composer require soatok/minisign
Usage (Command Line)
Creating a key pair
vendor/bin/minisign -G
Signing a file
vendor/bin/minisign -Sm myfile.txt
Or to include a comment in the signature, that will be verified and displayed when verifying the file:
vendor/bin/minisign -Sm myfile.txt -t 'This comment will be signed as well'
The signature is put into myfile.txt.minisig.
Multiple files can also be signed at once:
vendor/bin/minisign -Sm file1.txt file2.txt *.jpg
Verifying a file
vendor/bin/minisign -Vm myfile.txt -P RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3
or
vendor/bin/minisign -Vm myfile.txt -p signature.pub
This requires the signature myfile.txt.minisig to be present in the same directory.
The public key can either reside in a file (./minisign.pub by default) or be directly specified on the command line.
Usage (PHP Code)
Creating a key pair
<?php use Soatok\Minisign\Core\SecretKey; $secretKey = SecretKey::generate(); $password = 'correct horse battery staple'; $saveToFile = $secretKey->serialize($password); \file_put_contents('/path/to/secret.key', $saveToFile);
Signing a file
<?php use Soatok\Minisign\Core\SecretKey; use Soatok\Minisign\Core\File\MessageFile; $trustedComment = 'Trusted comment goes here'; $untrustedComment = 'Untrusted comment; can be changed'; $password = 'correct horse battery staple'; $preHash = false; // Set to TRUE to prehash the file $secretKey = SecretKey::fromFile('/path/to/secret.key', $password); $fileToSign = MessageFile::fromFile('/path/to/file'); $signature = $fileToSign->sign( $secretKey, $preHash, $trustedComment, $untrustedComment ); \file_put_contents( '/path/to/file.minisig', $signature->toSigFile()->getContents() );
Verifying a file
<?php use Soatok\Minisign\Core\PublicKey; use Soatok\Minisign\Core\File\{ MessageFile, SigFile }; $pk = PublicKey::fromFile('/path/to/minisign.pub'); $fileToCheck = MessageFile::fromFile('/path/to/file'); $signature = SigFile::fromFile('/path/to/file.minisig')->deserialize(); if (!$fileToCheck->verify($pk, $signature)) { echo 'Invalid signature!', PHP_EOL; exit(1); } $trusted = $signature->getTrustedComment();
soatok/minisign 适用场景与选型建议
soatok/minisign 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.54k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2020 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「signatures」 「digital signature」 「authenticity」 「minisign」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soatok/minisign 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soatok/minisign 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soatok/minisign 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
接口签名验证
Pure PHP implementation of pqcrypto; uses the PHP extension if it exists
A Laravel package to easily integrate Xendit payment gateway. It supports credit and debit cards, and e-wallet payments and custom invoices, queued notifications, webhook listeners and more.
Digital signature Nova field.
Guzzle middleware for HTTP Message Signatures (RFC9421) with web-bot-auth.
统计信息
- 总下载量: 22.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: ISC
- 更新时间: 2020-08-07