Best laravel framework open-source packages.

PHP Security Library

PSL is a security library for PHP. It provides advanced random data generation, encryption utilities as well as certificate generation and signing.
Updated 1 year ago

PHP Security Library

This library provides you a handful set of useful helper methods and classes related to security.

Examples

Encrypt data securely.
use \PSL\Encrypter;

$confidentalText = 'I am using PSL';

$cipherText = Encrypter::encrypt(MCRYPT_RIJNDAEL_128, $confidentalText);

// $cipherText is an instance of \PSL\CipherText.
// To extract, do something like this:
$key = $cipherText->key;
$plainText = Encrypter::decrypt($cipherText, $key);

// $plainText is now same as $confidentalText.
Generate strong random data.
use \PSL\Randomizer;

$data = Randomizer::getRandomBytes(32); // 32 bytes.

$randomFloat = Randomizer::getRandomFloat();

Things like random float generation is more conplex than what it might seem initially and therefore it's nice to be able to use a library for that.

Generate a certificate.
use \PSL\KeyPair;
use \PSL\Certificate;

$keyPair = new KeyPair();

$details = array(
    "countryName" => "FI",
    "stateOrProvinceName" => "Southern Finland",
    "localityName" => "Lahti",
    "organizationName" => "N/A",
    "organizationalUnitName" => "N/A",
    "commonName" => "localhost",
    "emailAddress" => "kaisellgren-at-gmail.com"
);

$certificate = new Certificate($details, $keyPair);

$certificate->sign();

file_put_contents('my.crt', $certificate->export());