hello,
I am sure I had doen this before but I have hit a liit snag...
I have to pass the encrypted string one one page to the next - either in a session or a hidden field. The probelm being the special characters in the string.
I have used a regular expression to replace line feeds etc... like so.
<?php
$this->find = array (
"/\\r/" ,
"/\\n/" ,
"/\\t/"
);
$this->replace = array (
'linefeedchar' ,
'newlinechar' ,
'tabchar'
);
$this->rfind = array (
"\r" ,
"\n" ,
"\t"
);
$this->rreplace = array (
'/linefeedchar/' ,
'/newlinechar/' ,
'/tabchar/'
);
// encrypting.
$encrypted = mcrypt_generic($this->td, $str);
return preg_replace($this->find, $this->replace,htmlentities($encrypted));
// decrypting
$str = html_entity_decode(preg_replace($this->rreplace, $this->rfind,$str));
return mdecrypt_generic($this->td, $str);
?>
obviously this is all in class methods - that is not the problem.
The problem lies with the characters of the encryption and converting them to ones that can be passed via post/session/url and then converted backonce more.
If you can spot where I am going wrong please put me right.
any thanks....