Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » RADICORE Suggestions » std.encryption.class.inc
std.encryption.class.inc [message #813] Tue, 08 May 2007 18:59 Go to previous message
cpscdave is currently offline  cpscdave
Messages: 20
Registered: June 2006
Junior Member
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 Smile

Nothing super complicated but figured it might save some people some time in the future.
-Dave Razz
 
Read Message
Read Message
Previous Topic: Business Process Mangement and Rules
Next Topic: path generalization
Goto Forum:
  


Current Time: Mon Nov 25 18:59:34 EST 2024

Total time taken to generate the page: 0.19324 seconds