diff --git a/README.md b/README.md index 84d9634..4856be5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Halite [![Build Status](https://travis-ci.org/paragonie/halite.svg?branch=stable)](https://travis-ci.org/paragonie/halite) +[![Latest Stable Version](https://poser.pugx.org/paragonie/halite/v/stable)](https://packagist.org/packages/paragonie/halite) +[![Latest Unstable Version](https://poser.pugx.org/paragonie/halite/v/unstable)](https://packagist.org/packages/paragonie/halite) +[![License](https://poser.pugx.org/paragonie/halite/license)](https://packagist.org/packages/paragonie/halite) + +> **Note**: This is the version 1 branch. Please upgrade to a newer version as soon as possible. Halite is a high-level cryptography interface that relies on [libsodium](https://pecl.php.net/package/libsodium) for all of its underlying cryptography operations. @@ -15,8 +20,43 @@ without making your source code available under a GPL-compatible license. ## Using Halite in Your Applications -1. [Install Libsodium and the PHP Extension](https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium) -2. `composer require paragonie/halite` +### Step 1: Installing libsodium + +Before you can use Halite, you must choose a version that fits the requirements +of your project. The differences between the requirements for the available +versions of Halite are briefly highlighted below. + +| | PHP | libsodium | PECL libsodium | +|-----------|-------|-----------|----------------| +| Halite 2+ | 7.0.0 | 1.0.9 | 1.0.6 | +| Halite 1 | 5.6.0 | 1.0.6 | 1.0.2 | + +If you plan to use Halite 1, or your distribution has the necessary version already, +then you should be able to +[install a precompiled libsodium](https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium) +package. + +### Step 2: Installing the PECL libsodium extension + +**Important Note**: It is important that this step is repeated every time that a +different version of libsodium is installed. The resulting PECL libsodium extension +is version dependent of the currently installed libsodium. + +Installation instructions for the PECL libsodium extension can be found in the +[PECL libsodium book](https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-extension) +on the Paragon Initiative Enterprises website. + +### Step 3: Use Composer to install Halite + +The last step required to use Halite is to install it using Composer. + +For the latest version of Halite: + + composer require paragonie/halite + +Or for older versions of Halite, specify the version number: + + composer require paragonie/halite:^v1 ## Using Halite in Your Project @@ -40,3 +80,68 @@ Check out the [documentation](doc). The basic Halite API is designed for simplic * Asymmetric * `Asymmetric\Crypto::sign`(`string`, [`SignatureSecretKey`](doc/Classes/Asymmetric/SignatureSecretKey.md), `bool?`): `string` * `Asymmetric\Crypto::verify`(`string`, [`SignaturePublicKey`](doc/Classes/Asymmetric/SignaturePublicKey.md), `string`, `bool?`): `bool` + +### Example: Encrypting and Decrypting a message + +First, generate and persist a key exactly once: + +```php +