Package Data | |
---|---|
Maintainer Username: | seffeng |
Maintainer Contact: | save.zxf@gmail.com (seffeng) |
Package Create Date: | 2020-05-20 |
Package Last Update: | 2023-06-06 |
Home Page: | https://packagist.org/packages/seffeng/laravel-rsa |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:20:35 |
Package Statistics | |
---|---|
Total Downloads: | 6,378 |
Monthly Downloads: | 173 |
Daily Downloads: | 7 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
# 安装
$ composer require seffeng/laravel-rsa
# 1、生成配置文件
$ php artisan vendor:publish --tag="rsa"
# 2、生成key文件
$ php artisan rsa:generate
# 1、将以下代码段添加到 /bootstrap/app.php 文件中的 Providers 部分
$app->register(Seffeng\LaravelRSA\RSAServiceProvider::class);
# 2、生成key文件
$ php artisan rsa:generate
# /storage 目录下对应 public key 提供给客户端
use Seffeng\LaravelRSA\Facades\RSA;
use Seffeng\LaravelRSA\Exceptions\RSAException;
class SiteController extends Controller
{
public function test()
{
try {
$plaintext = '123456';
// 加密
$entext = RSA::encrypt($plaintext);
// 解密
$detext = RSA::decrypt($entext);
$message = 'a=aaa&b=bbb&c=ccc';
// 签名
$sign = RSA::sign($message);
// 签名验证
$verify = RSA::verify($message, $sign);
var_dump(base64_encode($entext), $detext);
var_dump(base64_encode($sign), $verify);
} catch (RSAException $e) {
var_dump($e->getMessage());
} catch (\Exception $e) {
var_dump($e->getMessage());
}
}
}
| 依赖 | 仓库地址 | 备注 | | :------------------ | :------------------------------------- | :--- | | phpseclib/phpseclib | https://github.com/phpseclib/phpseclib | 无 |
无