ranabd36 / openssl-encryption
安全的 Laravel OpenSSL 公钥/私钥加密库
1.0.0
2018-08-09 07:42 UTC
Requires
- php: >=5.4.0
- ext-openssl: *
This package is auto-updated.
Last update: 2024-09-09 16:07:26 UTC
README
安全的 Laravel OpenSSL 公钥/私钥加密库。
介绍
OpenSSL 加密是 Laravel 公钥/私钥对加密包。它允许您生成公钥/私钥并使用该公钥/私钥加密和解密数据。
您想向您的朋友发送/接收安全消息。那么您必须生成公钥/私钥并将公钥发送给您的朋友。现在,您的其中一个朋友会使用您提供的公钥加密消息并发送给您。您收到消息后,使用您的私钥解密消息。
如果攻击者发现了消息,但攻击者没有您的私钥就无法解密它。因此,不要与任何人共享您的私钥。
安装(Laravel)
通过 composer 安装
composer require ranabd36/openssl-encryption:1.0.0
该包默认自动发现并注册,但如果您想自己注册
将服务提供者添加到 config/app.php 中的 providers 部分。
OpenSSLEncryption\Providers\OpenSSLEncryptionServiceProvider::class,
将别名添加到 config/app.php 中的 alias 部分。
OpenSSLEncryption\OpenSSL::class,
要发布配置,运行 vendor publish 命令
php artisan vendor:publish --provider="OpenSSLEncryption\Providers\OpenSSLEncryptionServiceProvider"
用法
要生成公钥/私钥,请运行以下 artisan 命令
php artisan openssl:key-generate
生成密钥后,您需要将您的公钥/私钥路径设置到 config/openss.php 并设置密码(如果您在生成密钥时设置了密码)。
加密数据
OpenSSL:encrypt('This text need to encrypt'); //This will return an encrypted data
解密数据
OpenSSL:decrypt('encrypted data'); //This will return plain text/data: This text need to encrypt
即将推出的功能
使用多个公钥/私钥进行加密和解密。
许可
OpenSSL 加密是开源软件,许可协议为 MIT 许可证