Objective PHP binding of OpenSSL Crypto library
C PHP C++ Other
Clone or download
Latest commit 42b50c1 May 1, 2017
Permalink
Failed to load latest commit information.
docs Fix typo (verifycation -> verification) Apr 22, 2017
examples Remove length parameter from Cipher::getTag Aug 25, 2015
phpc @ a9df7ae Update phpc Oct 26, 2015
tests Skip PBKDF2 tests if it is not supported Dec 13, 2016
utils Update API docs Dec 12, 2016
.gitignore ignore build files Nov 18, 2015
.gitmodules Add phpc submodule Apr 19, 2015
CREDITS Give me credit Dec 31, 2013
EXPERIMENTAL Initial commit containing ext skeleton May 30, 2013
HISTORY.md Release 0.3.1 Dec 15, 2016
LICENSE Fix Copyright years May 31, 2015
NEWS.md Release 0.3.1 Dec 15, 2016
README.md Link KDF and PBKDF2 docs in README Dec 9, 2016
TODO.md Update TODO Apr 30, 2017
config.m4 Add crypto_kdf to the config Sep 22, 2016
config.w32 Add crypto_kdf to the config Sep 22, 2016
crypto.c Call MINIT for crypto_kdf Oct 2, 2016
crypto_base64.c Move EVP_ENCODE_CTX compat code to the base64 implementation file Sep 14, 2016
crypto_cipher.c Fix typo (verifycation -> verification) Apr 22, 2017
crypto_hash.c Move HMAC compat code to the implementation file Sep 14, 2016
crypto_kdf.c Fix key_len type in php_crypto_kdf_set_key_len Dec 15, 2016
crypto_object.c Bump year Jan 6, 2016
crypto_rand.c Bump year Jan 6, 2016
crypto_stream.c Make compilation work with OpenSSL 1.1 Sep 14, 2016
package.xml Release 0.3.1 Dec 15, 2016
php_crypto.h Release 0.3.1 Dec 15, 2016
php_crypto_base64.h Make setting base64 encode and decode length compatible Sep 14, 2016
php_crypto_cipher.h Bump year Jan 6, 2016
php_crypto_hash.h Bump year Jan 6, 2016
php_crypto_kdf.h Add KDF length and all supporting function / fixes Oct 30, 2016
php_crypto_object.h Bump year Jan 6, 2016
php_crypto_rand.h Bump year Jan 6, 2016
php_crypto_stream.h Bump year Jan 6, 2016

README.md

PHP OpenSSL Crypto wrapper

The php-crypto is an objective wrapper for OpenSSL Crypto library.

Installation

Linux

Before starting with installation of this extensions, the OpenSSL library has to be installed. It is defaultly installed on the most Linux distributions. The minimal version of OpenSSL that is supported is 0.9.8 but it is recommended to have installed version 1.0.1+ to use all features.

Of course PHP has to be installed too. The minimal version that is supported is 5.3 as the extension uses namespaces. Currently PHP also needs to be compiled with OpenSSL extension (--with-openssl). This dependency will be removed in the future.

Fedora

The RPM package for PHP Crypto is available in Remi's repository: http://rpms.famillecollet.com/

It is available for Fedora, RHEL and clones (CentOS, SC and others).

After downloading remi-release RPM, the package can be installed by executing following command:

$ sudo yum --enablerepo=remi install php-pecl-crypto

PECL

This extension is available on PECL. The package is not currently stable. If the config preferre_state is stable, then the version needs to be specified.

$ sudo pecl install crypto-0.x.y

where x is an installed minor version number and y bug fixing version number.

Manual Installation

It's important to have a git installed as it's necessary for recursive fetch of phpc.

First clone recursively the repository

git clone --recursive https://github.com/bukka/php-crypto.git

Then go to the created directory and compile the extension. The PHP development package has to be installed (command phpize must be available).

cd php-crypto
phpize
./configure
make
sudo make install

Finally the following line needs to be added to php.ini

extension=crypto.so

Be aware that master branch contains a slightly different error handling. You can see examples for more details.

Windows

Precompiled binary dll libraries for php-crypto are available on the PECL crypto page.

The php-crypto dll is also available in Jan-E Windows builds on Apache Lounge.

API

The extension is still in development so the API is not stabilized yet.

All classes are defined in namespace Crypto.

Each base class has an exception class that has the same name and Exception suffix (e.g. Hash class has HashException. The exception classes are subclasses of the PHP Exception class. They define exception code as class constants. Each code also has a different message.

The documentation is devided to sections where can be found documentation of all class methods, constants and other related details:

PHP definition for the classes

The PHP based DocBlock documenation for all classes is generated from the extension code. It can be found in docs/Crypto.php. It can be also used for an IDE autocomplete.

Examples

The examples can be found in the example directory.

TODO list

There is lots of features on the TODO list.

History

The release history can be found HISTORY.md.