A library to encrypt or decrypt with random password generator based on secret key defined.
MIT License
This is the library for encrypting data with a key (password will be generate as per your parameters set) in PHP.
WHY ANOTHER LIBRARY? This was intended to developed for cross-platform AES Encryption here as PHP was missing. My main objective is to create library for AES-256-CBC
to contribute PHP package for Cross-Platform-AES package, more features will be added whenever I gets time.
mcrypt
has been deprecated.You can install the package via composer:
composer require ahsankhatri/cryptolib-php
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
$string = 'The quick brown fox jumps over to the lazy dog.';
$secretyKey = 'BlVssQKxzAHFAUNZbqvwS+yKw/m';
$encryption = new \MrShan0\CryptoLib\CryptoLib();
$cipher = $encryption->encryptPlainTextWithRandomIV($string, $secretyKey);
echo 'Cipher: ' . $cipher . PHP_EOL;
$plainText = $encryption->decryptCipherTextWithRandomIV($cipher, $secretyKey);
echo 'Decrypted: ' . $plainText . PHP_EOL;
$string = 'The quick brown fox jumps over to the lazy dog.';
$secretyKey = 'BlVssQKxzAHFAUNZbqvwS+yKw/m';
$encryption = new \MrShan0\CryptoLib\CryptoLib();
$iv = $encryption->generateRandomIV();
$cipher = $encryption->encrypt($string, $secretyKey, $iv);
echo 'Cipher: ' . $cipher . PHP_EOL;
$plainText = $encryption->decrypt($cipher, $secretyKey, $iv);
echo 'Decrypted: ' . $plainText . PHP_EOL;
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.