2017 © Pedro PelĂĄez
 

library php-encrypter

Encryption with AES-256 and HMAC-SHA256

image

adbario/php-encrypter

Encryption with AES-256 and HMAC-SHA256

  • Sunday, March 26, 2017
  • by adbario
  • Repository
  • 1 Watchers
  • 1 Stars
  • 168 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 26 % Grown

The README.md

PHP Encrypter

This project encrypts and decrypts the given value. It uses OpenSSL extension with AES-256 cipher for encryption and HMAC-SHA-256 for hash. The encryption and hash can use different keys., (*1)

PHP Encrypter requires PHP 5.3 or higher, OpenSSL and Multibyte String extensions., (*2)

Security Notice

As a reversible operation, encryption is not a secure solution for storing passwords. Always use hashing with salt per user for passwords., (*3)

Installation

With Composer:

composer require adbario/php-encrypter

Manual installation:

  1. Download the latest release
  2. Extract the files into your project
  3. require_once '/path/to/php-encrypter/src/Encrypter.php';
  4. If your PHP version is lower than 7, also polyfill for random_bytes() is required

Usage

Setup the encryption key:, (*4)

$key = '+NeXrQhAEhW}g8gf^y)Up8hAUKpue7wb';

Change the key to your own custom random 32 character string., (*5)

Create a new encrypter instance:, (*6)

$encrypter = new \Adbar\Encrypter($key);

If you wish to use a different key for hashing, you can pass it to constructor as a second parameter:, (*7)

$encrypter = new \Adbar\Encrypter($key, $authKey);

Encryption

Encrypt a string:, (*8)

$string = 'This is my string to encrypt.';
$encrypted = $encrypter->encryptString($string);

Encrypt other variable types with serialization:, (*9)

$array = array('key' => 'value');
$encrypted = $encrypter->encrypt($array);

Decryption

Decrypt a string:, (*10)

$string = $encrypter->decryptString($encrypted);

Decrypt other variable types with serialization:, (*11)

$array = $encrypter->decrypt($encrypted);

License

MIT license, (*12)

The Versions

26/03 2017

dev-master

9999999-dev https://github.com/adbario/php-encrypter

Encryption with AES-256 and HMAC-SHA256

  Sources   Download

MIT

The Requires

 

by Riku SĂ€rkinen

security encryption

26/03 2017

1.0.0

1.0.0.0 https://github.com/adbario/php-encrypter

Encryption with AES-256 and HMAC-SHA256

  Sources   Download

MIT

The Requires

 

by Riku SĂ€rkinen

security encryption