2017 © Pedro Peláez
 

library lib-crypt

Shorthand library for using AES encryption provided by PHP-Mcrypt

image

openlss/lib-crypt

Shorthand library for using AES encryption provided by PHP-Mcrypt

  • Wednesday, April 17, 2013
  • by nullivex
  • Repository
  • 2 Watchers
  • 4 Stars
  • 22,947 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 12 Versions
  • 4 % Grown

The README.md

lib-crypt

Shorthand library for using AES encryption provided by PHP-Mcrypt, (*1)

Usage

use \LSS\Crypt;

//create keys
$iv_key = Crypt::IVCreate();
$crypt_key = Crypt::keyCreate();

$crypt = Crypt::_get($crypt_key,$iv_key);
$crypted_str = $crypt->encrypt('my string'); //returns base64 encoded crypted string
$var = $crypt->decrypt($crypted_str); //returns 'my string'

Padding

By default MCrypt will NULL-PAD strings to get the proper encryption. However this creates problems when expecting exact payload encryption (such as binary), (*2)

Crypt deals with this by storing the size of the payload as the first 4 bytes in the returned string Crypt then extracts this size and trims the payload to the original size upon decrypt, (*3)

The downside to this is that it cant be decrypted by the regular MCrypt functions without first stripping the initial 4 bytes. It would be recommended to trim the payload if possible, (*4)

Reference

(string) Crypt::IVCreate()

Returns a proper initialization vector for the encryption type, (*5)

(string) Crypt::keyCreate()

Returns a proper secret key for the encryption type, (*6)

(object) Crypt::_get($key,$iv)

Shorthand for the construct that returns the new object, (*7)

(object) Crypt::setKey($key)

Change the key at runtime Returns $this so its chainable, (*8)

(object) Crypt::setIV($iv)

Change the IV at runtime Returns $this so its chainable, (*9)

(object) Crypt::verify()

Verifies the key and IV Will throw exceptions on errors Returns $this so its chainable, (*10)

(string) Crypt::encrypt($plain_string,$base64_encode=true)

  • $plain_string String to be encrypted
  • $base64_encode TRUE to base64_encode the encrypted string Returns the encrypted and optionally base64_encoded string

(string) Crypt::decrypt($enc_string,$base64_decode=true)

  • $enc_string The encrypted string to be decrypted
  • $base64_decode If the $enc_string is base64_encoded set to TRUE Returns the EXACT original string

The Versions

17/04 2013

dev-0.0.x-dev

dev-0.0.x-dev http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

17/04 2013

0.0.10

0.0.10.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

17/04 2013

dev-master

9999999-dev http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

07/04 2013

0.0.8

0.0.8.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

07/04 2013

0.0.9

0.0.9.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

07/04 2013

0.0.7

0.0.7.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

03/04 2013

0.0.6

0.0.6.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

27/03 2013

0.0.4

0.0.4.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

27/03 2013

0.0.5

0.0.5.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

26/03 2013

0.0.3

0.0.3.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

encryption aes decryption mcrypt

23/03 2013

0.0.2

0.0.2.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

encryption aes decryption mcrypt

23/03 2013

0.0.1

0.0.1.0 http://openlss.org

Shorthand library for using AES encryption provided by PHP-Mcrypt

  Sources   Download

LGPL-3.0+

The Requires

 

encryption aes decryption mcrypt