CodeIgniter Forums
encrypt class problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: encrypt class problem (/thread-9558.html)



encrypt class problem - El Forum - 06-30-2008

[eluser]PHPraja[/eluser]
hi guys...

i have used encrypt library for encryption of userids etc in my project. It works well in my local system but i m facing problem in client's centos system.
The problem is that in the encrypted string sometimes '/' is also present which CI treats as 2 different uri segments.

How to restrict '/' in the encrypted string.
The code i used as below
Code:
<a >encrypt->encode($docinfo['id']);?&gt;/&lt;?=$this->encrypt->encode('summary')?&gt;">

$this->encrypt->encode($docinfo['id']) - This is resulting to a encrypted string which includes '/' in it. This causes problem as CI treats as 2 different URI segments. How to solve this prob any one has idea ?

thanks
raja


encrypt class problem - El Forum - 06-30-2008

[eluser]Pascal Kriete[/eluser]
Base64 encoding it will solve the problem, although it isn't the most graceful solution.

The forum has become a little biased towards links in code tags Tongue .


encrypt class problem - El Forum - 06-30-2008

[eluser]Sumon[/eluser]
$this->encrypt->encode() use base64_encode() & base64_decode() function[Have a look /libraries/Encrypt.php].
So is it really solve this problem?


encrypt class problem - El Forum - 06-30-2008

[eluser]Pascal Kriete[/eluser]
Ignore what I said, I was being stupid. / is a valid character in the base64 alphabet.

New solution, replace / with another character.
Code:
$encoded = $this->encrypt->encode....
$encoded = strtr($encoded, '+/=', '-_,');

// And back again
$decoded = strtr($encoded, '-_,', '+/=');
$decoded = $this->encrypt->decode...



encrypt class problem - El Forum - 06-30-2008

[eluser]Yash[/eluser]
but it may conflict...I can't say


encrypt class problem - El Forum - 06-30-2008

[eluser]Pascal Kriete[/eluser]
What may conflict?


encrypt class problem - El Forum - 06-30-2008

[eluser]PHPraja[/eluser]
ok friends thanks for the answers.

At last i could solve it by commenting the mycrypt functions in /libraries/Encrypt.php (encode and decode functions)
Because of the mycrypt functions it is encoding the encoded string, which may result in '/' in that final encrypted string.