dev-master
9999999-devPHP Encryption / Decryption Using the MCrypt Library.
LGPL
The Requires
- php >=5.4.0
by ZeyOS, Inc.
1.0
1.0.0.0PHP Encryption / Decryption Using the MCrypt Library.
LGPL
The Requires
- php >=5.4.0
Wallogit.com
2017 © Pedro Peláez
PHP Encryption / Decryption Using the MCrypt Library.
THIS IS A MODIFIED VERSION OF THE cryptastic CLASS by Andrew Johnson, (*1)
The original code can be found at the following URL, (*2)
http://www.itnewb.com/v/PHP-Encryption-Decryption-Using-the-MCrypt-Library-libmcrypt, (*3)
$pass = 'the password';
$salt = 'the password salt';
$msg = 'This is the secret message.';
/**********************************************************************************************************************/
// EXAMPLE #1 USING STRING AS MESSAGE
$cryptastic = new cryptastic;
$key = $cryptastic->pbkdf2($pass, $salt, 1000, 32) or
die("Failed to generate secret key.");
$encrypted = $cryptastic->encrypt($msg, $key) or
die("Failed to complete encryption.");
$decrypted = $cryptastic->decrypt($encrypted, $key) or
die("Failed to complete decryption");
echo $decrypted . "<br /><br />\n";
/**********************************************************************************************************************/
// EXAMPLE #2 USING ARRAY AS MESSAGE
$msg = array('message' => $msg);
$encrypted = $cryptastic->encrypt($msg, $key);
$decrypted = $cryptastic->decrypt($encrypted, $key);
echo $decrypted['message'];
PHP Encryption / Decryption Using the MCrypt Library.
LGPL
PHP Encryption / Decryption Using the MCrypt Library.
LGPL