Reputation: 1548
I am working on a password system, where an email is sent and they have to click on a link to go to a page where the password is reset.
There is some information in the link which is encrypted, and then supposedly de-encrypted on the other side. Here is an example http://www.somewebpage.com?p=8e428904890e31a93c563e1f18c11ff6&c=U2FsdGVkX1+LdNFKzCZxRAGPYYA9MGzAhAUh/wLJ3T4=
Now I use $_GET['c'] to get the encrypted data. Then I decrypt it using my Decrypt code.
Now here is the problem If I do this it works
Decrypt($key,"U2FsdGVkX1+LdNFKzCZxRAGPYYA9MGzAhAUh/wLJ3T4=");
and it gives me back my original text.
but if I do this. It doesn't work
Decrypt($key,$_GET['c']);
It just gives me mangled characters.
The question is why doesn't my encrypt routine work when I user $_GET['c'] and works if I put the string in directly.
Is the web url adding hidden characters or something? If so can I strip anything added.
Upvotes: 0
Views: 78
Reputation: 86
The encrypt data contain some character that will not pass through browser correctly.
When you are generate the key try to use function urlencode()
echo '<a href="mycgi?foo=', urlencode($encryptdata), '">';
Upvotes: 2