1# PHP OpenSSL Crypto wrapper 2 3The php-crypto is an objective wrapper for OpenSSL Crypto library. 4 5 6## Installation 7 8### Linux 9 10Before starting with installation of this extensions, the `OpenSSL` library 11has to be installed. It is defaultly installed on the most Linux distributions. 12The minimal version of OpenSSL that is supported is 0.9.8 but it is recommended 13to have installed version 1.0.1+ to use all features. 14 15Of course PHP has to be installed too. The minimal version that is supported is 165.3 as the extension uses namespaces. Currently PHP also needs to be compiled 17with OpenSSL extension (`--with-openssl`). This dependency will be removed 18in the future. 19 20#### Fedora 21 22The RPM package for PHP Crypto is available in Remi's repository: 23http://rpms.famillecollet.com/ 24 25It is available for Fedora, RHEL and clones (CentOS, SC and others). 26 27After downloading remi-release RPM, the package can be installed 28by executing following command: 29``` 30$ sudo yum --enablerepo=remi install php-pecl-crypto 31``` 32 33#### PECL 34 35This extension is available on PECL. The package is not currently stable. 36If the config `preferre_state` is stable, then the version needs to be specified. 37 38``` 39$ sudo pecl install crypto-0.x.y 40``` 41 42where `x` is an installed minor version number and `y` bug fixing version number. 43 44 45#### Manual Installation 46 47It's important to have a git installed as it's necessary for recursive fetch of 48[phpc](https://github.com/bukka/phpc). 49 50First clone recursively the repository 51``` 52git clone --recursive https://github.com/bukka/php-crypto.git 53``` 54 55Then go to the created directory and compile the extension. The PHP development 56package has to be installed (command `phpize` must be available). 57``` 58cd php-crypto 59phpize 60./configure 61make 62sudo make install 63``` 64 65Finally the following line needs to be added to `php.ini` 66``` 67extension=crypto.so 68``` 69 70Be aware that master branch contains a slightly different error handling. 71You can see examples for more details. 72 73### Windows 74 75Precompiled binary `dll` libraries for php-crypto are available 76on [the PECL crypto page](http://pecl.php.net/package/crypto). 77 78The php-crypto `dll` is also available in Jan-E Windows builds 79on [Apache Lounge](https://www.apachelounge.com/viewforum.php?f=6). 80 81 82## API 83 84The extension is still in development so the API is not stabilized yet. 85 86All classes are defined in namespace `Crypto`. 87 88Each base class has an exception class that has the same name and 89`Exception` suffix (e.g. `Hash` class has `HashException`. The exception 90classes are subclasses of the PHP `Exception` class. They define 91exception code as class constants. Each code also has a different message. 92 93The documentation is devided to sections where can be found documentation 94of all class methods, constants and other related details: 95 96- **[Base64](docs/base64.md)** 97- **[Cipher](docs/cipher.md)** 98- **[CMAC](docs/cmac.md)** 99- **[Hash](docs/hash.md)** 100- **[HMAC](docs/hmac.md)** 101- **[MAC](docs/mac.md)** 102- **[KDF](docs/kdf.md)** 103- **[PBKDF2](docs/pbkdf2.md)** 104- **[Rand](docs/rand.md)** 105- **[Streams](docs/streams.md)** 106 107 108### PHP definition for the classes 109 110The PHP based DocBlock documenation for all classes is 111generated from the extension code. It can be found in 112[docs/Crypto.php](docs/Crypto.php). It can be also 113used for an IDE autocomplete. 114 115 116## Examples 117 118The examples can be found in [the example directory](examples). 119 120 121## TODO list 122 123There is lots of features on the [TODO list](TODO.md). 124 125 126## History 127 128The release history can be found [HISTORY.md](HISTORY.md). 129