2017 © Pedro Peláez
 

library aes

OpenSSL-compatible AES library

image

legierski/aes

OpenSSL-compatible AES library

  • Tuesday, June 24, 2014
  • by legierski
  • Repository
  • 2 Watchers
  • 6 Stars
  • 8,681 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

legierski/AES

Perform AES-256 (CBC) encryption/decryption compatible with OpenSSL, CryptoJS, Gibberish AES and possibly other libraries., (*1)

Can be used to encrypt data in PHP and decrypt in JavaScript, or vice versa., (*2)

Code from here: http://uk3.php.net/manual/en/function.openssl-decrypt.php#107210, (*3)

Requirements

  • PHP 5.3.3 or later
  • OpenSSL extension for PHP

Installation

In composer.json:, (*4)

``` json { "require": { "legierski/aes": "0.1.*" } }, (*5)


## Encrypting data ``` php $aes = new \Legierski\AES\AES; $encrypted = $aes->encrypt('Very sensitive data', 'password'); // OpenSSL will truncate rows longer than 76 characters, so let's wrap our encrypted data $encryptedForOpenSSL = $aes->wrapForOpenSSL($encrypted);

Decrypting data

``` php $aes = new \Legierski\AES\AES;, (*6)

$decrypted = $aes->decrypt('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password');, (*7)


## Encrypting/decrypting with OpenSSL ``` bash $ echo "Very sensitive data" | openssl enc -aes-256-cbc -a -k password $ echo "U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF" | openssl enc -aes-256-cbc -a -d -k password

Encrypting/decrypting with CryptoJS

``` js var encrypted = CryptoJS.AES.encrypt('Very sensitive data', 'password').toString();, (*8)

var decrypted = CryptoJS.AES.decrypt('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password').toString(CryptoJS.enc.Utf8);, (*9)


## Encrypting/decrypting with Gibberish AES ``` js var encrypted = GibberishAES.enc('Very sensitive data', 'password'); var decrypted = GibberishAES.dec('U2FsdGVkX1+nnmEfHgoGQpwSPcT+mDZHxhr8XhEsmIvT2JAxsIzsRocO6x1PErrF', 'password');

Testing

Run unit tests:, (*10)

``` bash $ ./vendor/bin/phpunit, (*11)


Test compliance with [PSR2 coding style guide](http://www.php-fig.org/psr/psr-2/): ``` bash $ ./vendor/bin/phpcs --standard=PSR2 ./src

License

The MIT License (MIT), (*12)

The Versions

24/06 2014

dev-master

9999999-dev

OpenSSL-compatible AES library

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-openssl *

 

The Development Requires

encryption aes openssl rijndael decryption mcrypt cryptojs gibberish aes

24/06 2014

0.1.0

0.1.0.0

OpenSSL-compatible AES library

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-openssl *

 

The Development Requires

encryption aes openssl rijndael decryption mcrypt cryptojs gibberish aes