You need to have MCRYPT installed.
Here's a crypt/decrypt set for use with the later versions of mCrypt, it uses 256-bit AES grade encryption with RINDAEL...
pretty basic stuff really:
function ENCRYPT($STR) {
$IV = mcrypt_create_iv(mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_EC😎, MCRYPT_RAND);
$cryptText = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, @constant('myKey'), $STR, MCRYPT_MODE_ECB, $IV);
return $cryptText;
}
function DECRYPT($STR) {
$IV = mcrypt_create_iv(mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256, MCRYPT_MODE_EC😎, MCRYPT_RAND);
$myText = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, @constant('myKey'), $STR, MCRYPT_MODE_ECB, $IV);
return $myText;
}
...note the: @constant('myKey') -- I set my encrypt keys well outside the rest of the code. You can just change that bit to say $myKey if you wish, but recommend doing something fancy with your sensitive data.