Skip to content

kaisellgren/PHP-Security-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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());

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors