A librairy to use easiely the openssl encryption/decryption

1.0.0 2020-10-31 14:34 UTC

This package is auto-updated.

Last update: 2023-09-29 02:38:40 UTC


PHP Packagist version Packagist License Gitlab pipeline status


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.


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.


The project is under lincence MIT.