smakecloud / laravel-sodium
Laravel libsodium
Requires
- php: ^8.1
- ext-sodium: ^8.1
- illuminate/support: ^8.0|^9.0|^10.0
- laravel/framework: ^8.0|^9.0|^10.0
Requires (Dev)
- brianium/paratest: ^6.10
- laravel/pint: ^1.4
- nunomaduro/larastan: ^2.0
- orchestra/testbench: ^7.22
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^7.2|^8.4|^9.5
This package is not auto-updated.
Last update: 2024-11-07 16:47:14 UTC
README
Uses PHP's Sodium extension to encrypt, decrypt, sign and verify data.
Note Package name was chosen for discoverability. It is not affiliated with Laravel.
Supported encryption ciphers are:
Supported signing algorithms are:
Signing KeyPair is generated using app.key
for seeding.
Warning This package overrides Laravel's Encrypter class!
You will lose support for the following ciphers:
- AES-128-CBC
- AES-256-CBC
- AES-128-GCM
Table of Contents
Requirements
- PHP 8.1+
- Sodium extension ( obviously )
Installation
You can install the package via composer:
composer require smakecloud/laravel-sodium
This package uses Laravel's auto-discovery feature. After you install it the package provider and facade are available immediately.
Usage
This package overrides Laravel's Encrypter class. You can use it as you would use the default Encrypter class.
You can change the default cipher in:
config/app.php
return [ //... 'cipher' => 'XCha-Cha20-Poly1305', //... ]
$encrypted = encrypt('secret'); $decrypted = decrypt($encrypted); // 'secret' $signed = sign('secret'); $verified = verify($signed); // 'secret' $signature = sign_detached('secret'); $verified = verify_detached($signature, 'secret'); // true
Development
Testing
composer test
Coverage
composer test:coverage
Static analysis
composer phpstan
Code style
composer lint(:fix)
Disclaimer
This package is not affiliated with Laravel in any way.
Read the documentation of PHPs sodium extension before using this package !
We don't take any responsibility for any damage caused by this package.
License
The MIT License (MIT). Please see License File for more information.