I'm not sure if other people would need this, but occasionally I've found it useful to store data that needs to obscured from normal users.
I really like using the encryption class as it saves me from having to build my own obfuscation. However it doesn't support serialized objects.
Here is a quick and dirty change I've made to allow me to pass serialized objects to it.
Add these 2 functions to encryption_class
/******************************************************
* Added by Dave Robertson <http://www.softelephant.com
*******************************************************/
function remove_key_chars($val)
{
$temp = str_replace("\"","@@DBLQOUTE@@",$val);
$temp = str_replace("\'","@@SGLQOUTE@@",$temp);
$temp = str_replace("\\","@@SLASH@@",$temp);
return $temp;
}
function replace_key_chars($val)
{
$temp = str_replace("@@DBLQOUTE@@","\"",$val);
$temp = str_replace("@@SGLQOUTE@@","'",$temp);
$temp = str_replace("@@SLASH@@","\\",$temp);
return $temp;
}
Then modify encrypt to have at the start
function encrypt ($key, $source, $sourcelen = 0)
// encrypt string into a garbled form
{
$source = $this->remove_key_chars($source);
...
and modify decrypt to have at the end
...
$target = $this->replace_key_chars($target);
return rtrim($target);
} // decrypt
I've attached a modified version of the file
Nothing super complicated but figured it might save some people some time in the future.
-Dave