2017 © Pedro Peláez
 

library halite

High-level cryptography interface powered by libsodium

image

guazi/halite

High-level cryptography interface powered by libsodium

  • Thursday, March 23, 2017
  • by leo2018
  • Repository
  • 1 Watchers
  • 0 Stars
  • 503 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 47 Forks
  • 0 Open issues
  • 43 Versions
  • 3 % Grown

The README.md

Halite

Build Status Latest Stable Version Latest Unstable Version License, (*1)

Halite is a high-level cryptography interface that relies on libsodium for all of its underlying cryptography operations., (*2)

Halite was created by Paragon Initiative Enterprises as a result of our continued efforts to improve the ecosystem and make cryptography in PHP safer and easier to implement., (*3)

It's released under the GPLv3 license. Commercial licenses are available from Paragon Initiative Enterprises if you wish to implement Halite in an application without making your source code available under a GPL-compatible license., (*4)

Using Halite in Your Applications

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., (*5)

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 2+, you might need to compile libsodium from source since your distribution probably won't have the necessary version quite yet., (*6)

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 package., (*7)

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., (*8)

Installation instructions for the PECL libsodium extension can be found in the PECL libsodium book on the Paragon Initiative Enterprises website., (*9)

Step 3: Use Composer to install Halite

The last step required to use Halite is to install it using Composer., (*10)

For the latest version of Halite:, (*11)

composer require paragonie/halite

Or for older versions of Halite, specify the version number:, (*12)

composer require paragonie/halite:^v1

Using Halite in Your Project

Check out the documentation. The basic Halite API is designed for simplicity:, (*13)

Example: Encrypting and Decrypting a message

First, generate and persist a key exactly once:, (*14)

<?php
use ParagonIE\Halite\KeyFactory;

$encKey = KeyFactory::generateEncryptionKey();
KeyFactory::save($encKey, '/path/outside/webroot/encryption.key');

And then you can encrypt/decrypt messages like so:, (*15)

<?php
use ParagonIE\Halite\HiddenString;
use ParagonIE\Halite\KeyFactory;
use ParagonIE\Halite\Symmetric\Crypto as Symmetric;

$encryptionKey = KeyFactory::loadEncryptionKey('/path/outside/webroot/encryption.key');

$message = new HiddenString('This is a confidential message for your eyes only.');
$ciphertext = Symmetric::encrypt($message, $encryptionKey);

$decrypted = Symmetric::decrypt($ciphertext, $encryptionKey);

var_dump($decrypted === $message); // bool(true)

This should produce something similar to:, (*16)

MUIDAEpQznohvNlQ-ZRk-ZZ59Mmox75D_FgAIrXY2cUfStoeL-GIeAe0m-uaeURQdPsVmc5XxRw3-2x5ZAsZH_es37qqFuLFjUI-XK9uG0s30YTsorWfpHdbnqzhRuUOI09c-cKrfMQkNBNm0dDDwZazjTC48zWikRHSHXg8NXerVDebzng1aufc_S-osI_zQuLbZDODujEnpbPZhMMcm4-SWuyVXcBPdGZolJyT

Example: Generating a key from a password

<?php
use ParagonIE\Halite\HiddenString;
use ParagonIE\Halite\KeyFactory;

$passwd = new HiddenString('correct horse battery staple');
// Use random_bytes(16); to generate the salt:
$salt = "\xdd\x7b\x1e\x38\x75\x9f\x72\x86\x0a\xe9\xc8\x58\xf6\x16\x0d\x3b";

$encryptionKey = KeyFactory::deriveEncryptionKey($passwd, $salt);

A key derived from a password can be used in place of one randomly generated., (*17)

Example: Encrypting a large file on a system with low memory

Halite includes a file cryptography class that utilizes a streaming API to allow large files (e.g. gigabytes) be encrypted on a system with very little available memory (i.e. less than 8 MB)., (*18)

<?php
use ParagonIE\Halite\File;
use ParagonIE\Halite\KeyFactory;

$encryptionKey = KeyFactory::loadEncryptionKey('/path/outside/webroot/encryption.key');

File::encrypt('input.txt', 'output.txt', $encryptionKey);

The Versions

23/03 2017

dev-stable

dev-stable

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

The Development Requires

23/03 2017

1.5.6

1.5.6.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

The Development Requires

21/03 2017

dev-master

9999999-dev

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

The Development Requires

20/03 2017

1.5.4

1.5.4.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

The Development Requires

20/03 2017

v1.5.3

1.5.3.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.5.9 || ^7.0.0
  • ext-libsodium ^1.0.2

 

The Development Requires

10/03 2017

dev-php5.5_compat

dev-php5.5_compat

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.5.9 || ^7.0.0
  • ext-libsodium ^1.0.2

 

The Development Requires

10/03 2017

v1.5.2

1.5.2.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.5.9 || ^7.0.0
  • ext-libsodium ^1.0.2

 

The Development Requires

08/12 2016

v3.2.0

3.2.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

27/10 2016

v3.1.1

3.1.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

22/08 2016

v2.2.x-dev

2.2.9999999.9999999-dev

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

22/08 2016

v2.2.0

2.2.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

22/08 2016

v3.1.0

3.1.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

30/07 2016

v3.0.0

3.0.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

 

29/07 2016

v1.5.1

1.5.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

29/07 2016

v2.1.x-dev

2.1.9999999.9999999-dev

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

29/07 2016

v2.1.3

2.1.3.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

11/07 2016

v2.1.2

2.1.2.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

15/05 2016

v2.1.1

2.1.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

07/05 2016

v2.1.0

2.1.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.6

 

21/04 2016

v2.0.x-dev

2.0.9999999.9999999-dev

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.3

 

21/04 2016

v2.0.1

2.0.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.3

 

15/04 2016

dev-mad-science

dev-mad-science

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.3

 

04/04 2016

v2.0.0

2.0.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^7.0.0
  • ext-libsodium ^1.0.3

 

08/03 2016

v1.5.0

1.5.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

17/02 2016

1.4.0

1.4.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

17/01 2016

1.3.2

1.3.2.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

14/01 2016

1.3.1

1.3.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

30/12 2015

1.3.0

1.3.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

14/11 2015

1.2.0

1.2.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

06/11 2015

1.1.0

1.1.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

06/11 2015

1.0.0

1.0.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.2

 

03/11 2015

0.8.1

0.8.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.1

 

02/11 2015

0.8.0

0.8.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.1

 

30/10 2015

0.7.0

0.7.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.1

 

26/10 2015

0.6.0

0.6.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0.1

 

17/10 2015

0.5.2

0.5.2.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0

 

15/10 2015

0.5.1

0.5.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0

 

14/10 2015

0.5.0

0.5.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0

 

14/10 2015

0.4.0

0.4.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0

 

12/10 2015

0.3.2

0.3.2.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0 || ^7.0.0
  • ext-libsodium ^1.0

 

09/10 2015

0.3.1

0.3.1.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • php ^5.6.0
  • ext-libsodium ^1.0

 

08/10 2015

0.3.0

0.3.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • ext-libsodium ^1.0

 

23/09 2015

0.1.0

0.1.0.0

High-level cryptography interface powered by libsodium

  Sources   Download

GPL3

The Requires

  • ext-libsodium ^1.0