slam / php-symmetric-encryption
PHP Symmetric Encryption
Fund package maintenance!
Slamdunk
paypal.me/filippotessarotto
Installs: 11 641
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- php: ~8.3.0 || ~8.4.0
- ext-sodium: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64.0
- infection/infection: ^0.29.6
- phpstan/phpstan: ^1.12.4
- phpstan/phpstan-phpunit: ^1.4.0
- phpunit/phpunit: ^11.3.6
This package is auto-updated.
Last update: 2024-12-21 11:13:48 UTC
README
V1: encrypt strings with sodium_crypto_aead_xchacha20poly1305_ietf_encrypt
function.
Installation
To install with composer run the following command:
$ composer require slam/php-symmetric-encryption
Usage
use SlamSymmetricEncryption\V1Encryptor; // Generate a key and save it somewhere $key = V1Encryptor::generateKey(); var_dump($key); // string(44) "Hog2u9jtOzyt+mPyAJwp8v3dI6Uvp1T4FUKrAjizVGo=" // Use the key $encryptor = new V1Encryptor($key); $ciphertext = $encryptor->encrypt('foo'); var_dump($ciphertext); // string(59) "dznmjbqHnI_26crKpRYvp125K9N6ctqU0kVCmoSRbG7HAKCIrnAz0RBELQ" $plaintext = $encryptor->decrypt($ciphertext); var_dump($plaintext); // string(3) "foo"