This library provides hash and encryption tools that makes a lot easier to work with both of those things. Rather than having cipher and algorithm, cipher keys, hash secrets and so on, spread around in your entire project, this crypt package enables you to deal with all of this in one place and then make use it from anywhere.
Cipher & Hash algorithm
This is setup during initialization of the class instances. From here you can simply forward these instances to anywhere in your project, and it will all make use of the same ciphers and algorithms when creating hash values, encrypting data and so fourth.
Secret, Cipher Key & Salt/IV
Maybe you would want to create keyed hash values of passwords before database storage? Or you might want to sign and/or encrypt cookie data? Maybe do something to session data? But you don't want to deal with setting up secrets and salt values or iv's and cipher keys directly in a custom cookie, session library or a login page. The crypt package allows you to specify shared secrets/salts and keys/iv's within each of the respected instances. These can be used across your project, allowing your cookie/session library and your login/create profile page to only deal with the actual encryption/decryption and hash work.
$crypt = new OpenSSLCrypt("aes-256-cbc");
$crypt->setCipherKey($key);
$crypt->setCipherIv($iv);
// Encrypt data
$cipherText = $crypt->encrypt($data);
// Decrypt
$data = $crypt->decrypt($cipherText);
You can view the Full Documentation to lean more.
Using .phar library
wget https://github.com/IMPHP/crypt/releases/download/<version>/imphp-crypt.phar
require "imphp-crypt.phar";
...
Clone via git
git clone https://github.com/IMPHP/crypt.git imphp/crypt/
Composer (Packagist)
composer require imphp/crypt