nolikein / simple-cryptor
A librairy to use easiely the openssl encryption/decryption
Requires
- php: ^7.3
Requires (Dev)
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2023-09-29 02:38:40 UTC
README
Overview
This librairy allow to basically encrypt and decrypt content easiely. It is good for studying but do not use it in system which research a high level of security. Actually, this librairy cannot use GCM tag and do not support many options.
Install
Use composer, in simple command line:
composer require nolikein/simple-cryptor ^1.0.0
Use composer with Docker:
docker run --rm --interactive --tty -v $PWD:/app composer require nolikein/simple-cryptor ^1.0.0
Using it !
$message = 'Hello world!';
$key = openssl_random_pseudo_bytes(32);
$encrypter = new SimpleCryptor();
$encryptedmessage = $encrypter->encrypt($message, $key);
$decryptedMessage = $encrypter->decrypt($encryptedmessage, $key);
Choose a cipher (encrypt/decrypt method) and a hash method
The key is hashed by the hash method before encrypting/decrypting. These data are selected in the constructor :
$encrypter = new SimpleCryptor('aes-256-cfb', 'sha512');
By default, there is values to simplify the use of the librairy.
Licence
The project is under lincence MIT.