Shorthand library for using AES encryption provided by PHP-Mcrypt
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'
By default MCrypt will NULL-PAD strings to get the proper encryption. However this creates problems when expecting exact payload encryption (such as binary)
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
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
Returns a proper initialization vector for the encryption type
Returns a proper secret key for the encryption type
Shorthand for the construct that returns the new object
Change the key at runtime Returns $this so its chainable
Change the IV at runtime Returns $this so its chainable
Verifies the key and IV Will throw exceptions on errors Returns $this so its chainable
Language | php |
Version | 0.0.0 |
Git URL | https://github.com/nullivex/lib-crypt |
License | GPL-3.0 |
Description | Shorthand library for using AES encryption provided by PHP-Mcrypt |
Keywords |