jmrashed/laravel-cryptographic-signatures
Composer 安装命令:
composer require jmrashed/laravel-cryptographic-signatures
包简介
A Laravel package for cryptographic signature generation and verification.
README 文档
README
A Laravel package for generating and verifying cryptographic signatures using RSA keys. This package provides easy-to-use methods for securing your data through signatures, ensuring authenticity and integrity.
Installation
You can install the package via Composer by running the following command in your Laravel project:
composer require jmrashed/laravel-cryptographic-signatures
Publishing Configuration
Publish the package's configuration file to customize your keys:
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config"
This will create a cryptosignature.php file in the config/ directory, where you can specify the paths to your private and public keys.
Configuration
In your .env file, set the paths to your private and public keys:
CRYPTO_PRIVATE_KEY=storage/keys/private.key CRYPTO_PUBLIC_KEY=storage/keys/public.key
How to generate RSA keys: storage/keys/private.key and storage/keys/public.key
openssl genrsa -out storage/keys/private.key 2048 openssl rsa -in storage/keys/private.key -pubout -out storage/keys/public.key
Make sure your keys are stored securely in the specified paths.
How to publish config and keys
php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="config" php artisan vendor:publish --provider="Jmrashed\LaravelCryptographicSignatures\Providers\CryptoSignaturesServiceProvider" --tag="keys"
Usage
Once the package is installed and configured, you can easily generate and verify cryptographic signatures.
Generating a Signature
Use the CryptoSignature facade to generate a signature for your data.
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature; $data = 'Sensitive data to be signed'; $signature = CryptoSignature::generateSignature($data); echo "Generated Signature: " . $signature;
Verifying a Signature
You can also verify a signature to ensure the integrity and authenticity of the data.
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature; $data = 'Sensitive data to be verified'; $signature = 'previouslyGeneratedSignature'; $isVerified = CryptoSignature::verifySignature($data, $signature); if ($isVerified) { echo "The signature is valid!"; } else { echo "The signature is invalid!"; }
Features
- Generate cryptographic signatures: Safely sign your data with a private key.
- Verify signatures: Ensure the authenticity and integrity of data with a public key.
- Flexible configuration: Easily set custom key paths through Laravel’s config system.
Example
Here’s a complete example that demonstrates generating and verifying a signature:
use Jmrashed\LaravelCryptographicSignatures\Facades\CryptoSignature; $data = 'Sensitive data to be signed'; // Generate the signature $signature = CryptoSignature::generateSignature($data); // Verify the signature $isVerified = CryptoSignature::verifySignature($data, $signature); if ($isVerified) { echo "The data is verified!"; } else { echo "Signature verification failed!"; }
Testing
To run tests for the package, use the following command:
php artisan test
Make sure your keys are properly configured in the .env file before running the tests.
License
The package is open-sourced software licensed under the MIT license.
Contributing
Contributions are welcome! Please feel free to fork the repository, submit issues, and send pull requests.
- Fork the repo and clone it to your local machine
- Create a new branch for your changes
- Write tests for new features or bug fixes
- Submit a pull request with a description of your changes
Support
If you encounter any issues or have questions, feel free to open an issue in the GitHub repository.
Acknowledgments
- Thanks to Laravel for its amazing framework that makes building packages so easy!
- OpenSSL for providing secure cryptographic tools that power this package.
jmrashed/laravel-cryptographic-signatures 适用场景与选型建议
jmrashed/laravel-cryptographic-signatures 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「security」 「Authentication」 「cryptography」 「signature」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jmrashed/laravel-cryptographic-signatures 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jmrashed/laravel-cryptographic-signatures 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jmrashed/laravel-cryptographic-signatures 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DUKPT implementation in PHP
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Provide a way to secure accesses to all routes of an symfony application.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
A library for reading KeePass 2.x databases
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-14