CodeIgniter Forums

Full Version: encrypt class problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

[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 .

El Forum

[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?

El Forum

[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...

El Forum

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

El Forum

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

El Forum

[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.