nolikein/simple-cryptor

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: 2024-04-29 04:27:45 UTC


README

PHP Packagist version Packagist License Gitlab pipeline status

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.