dev-master
9999999-dev https://github.com/ezimuel/phpcryptoCryptographic library for PHP 7 based on OpenSSL
MIT
The Requires
- php >=7.0
- ext-openssl *
The Development Requires
cryptography php7
Wallogit.com
2017 © Pedro Peláez
Cryptographic library for PHP 7 based on OpenSSL
This is a cryptography library for PHP 7. It's based on OpenSSL and provides the following features:, (*2)
As this software is ALPHA, Use at your own risk!, (*3)
The usage is quite straightforward, after installing the library using composer:, (*4)
composer require ezimuel/phpcrypto:dev-master
You can consume the following classes Symmetric, PublicKey and Hybrid for symmetric encryption, public key and hybrid encryption., (*5)
For instance, if you want to encrypt a string in a symmetric way, you can use the following code:, (*6)
use PHPCrypto\Symmetric;
$plaintext = 'Text to encrypt';
$key = '123456789012'; // This can be also a user's password we generate a new
// one for encryption using PBKDF2 algorithm
$cipher = new Symmetric(); // AES + HMAC-SHA256 by default
$cipher->setKey($key);
$ciphertext = $cipher->encrypt($plaintext);
// or passing the $key as optional paramter
// $ciphertext = $cipher->encrypt($plaintext, $key);
$result = $cipher->decrypt($ciphertext);
// or passing the $key as optional paramter
// $result = $cipher->decrypt($ciphertext, $key);
print ($result === $plaintext) ? "OK" : "FAILURE";
In this project we used the following security best practices:, (*7)
Min size of user's key for encryption set to 12, (*8)
Source: https://en.wikipedia.org/wiki/Password_strength, (*9)
Use of PBKDF2 to generate the encryption and authentication key. Set the default iteration number to 80'000 (min 20'000), (*10)
Source: https://goo.gl/bzv4dK, (*11)
Encryption-then-authentication using HMAC, (*12)
Source: http://crypto.stackexchange.com/a/205, (*13)
Use of OAEP padding for OpenSSL public key encryption, (*14)
Source: http://crypto.stackexchange.com/a/12706, (*15)
Here I reported some notes about the OpenSSL PHP extension usage:, (*16)
Copyright 2016 by Enrico Zimuel, (*17)
The license usage is reported in the LICENSE file., (*18)
Cryptographic library for PHP 7 based on OpenSSL
MIT
cryptography php7