tankfairies / laravel-tcrypt
Laravel Sodium加密
1.0.2
2024-02-17 15:49 UTC
Requires
- php: ^8.2
- ext-sodium: *
- tankfairies/tcrypt: 2.*
Requires (Dev)
README
Laravel Tcrypt
此Laravel包可用于使用Sodium进行双向加密。
安装
使用Composer安装
composer require tankfairies/laravel-tcryppt
Laravel
在config/app.php
文件中注册包服务提供者。
'providers' => [ Tankfairies\LaravelTcrypt\GuidServiceProvider::class, ]
公钥
如何生成您的公钥。发送者和接收者交换这些。
$publicKey = generate_public_tkey('your_password', 'your_salt');
公钥看起来可能如下所示:-
a322e905bd29167702bfc816a6e5ad2be0d8ede171d3c6e68497a5ef5b316d08
加密消息
如何加密消息。
$encryptedMessage = tcrypt( 'encrypt', 'your_password', 'your_salt', 'my secret message', 'the_public_key_from_the_receiver');
这将产生类似以下的内容:-
9G/vMg4piI778CzVpjcOL/c4kGV7+j0ih+JfuYh0QzWYyfAvwQcy1tW8jXcrb2Fd5aRvkljTeQ55
解密消息
如何解密消息。
$decryptedMessage = tcrypt( 'decrypt', 'your_password', 'your_salt', 'the encrypted message', 'the_public_key_from_the_sender');
这将产生类似以下的内容:-
我的秘密消息
版权和许可证
tankfairies/laravel-guid库版权为(c) 2019 Tankfairies (https://tankfairies.com),并根据MIT许可证(MIT)授权使用。