symfony1 - PHP: problems with url encoding (rawurlencode and rawurldecode) -


i creating token passing part of url on page. encode string using rawurlencode() , send token, however, find when decode received token (passed url parameter), different string.

my url looks this: /path/to/file.html?token=abcd123

here snippet of code using. doing erong?. failing that, there better way create (encrypted) tokens , pass them in url?

<?php //send  $raw = "some secret string"; $token = rawurlencode($raw);   //recieve $data = rawurldecode($token);  ?> 

[edit]

i have removed enc(dec)ryption functionality - not cause of problem - , red herring. have narrowed problem down rawurlencode/decode not being symmetric in way working.

a rawurlencoded string when decoded, giving different string (similar string, parts missing). surely, there cant bug in fundamental urls - must doing wrong. problem can't spot it, , far no 1 else seems able spot either ...

[additional info]

i using symfony web framework (v1.3.8), messing requests encoding , decoding stuff behind scenes. going try token parameter directly $_post variable , see if symfony culprit in of this.

you shouldn't need rawurldecode token when receive url, because php handles you. e.g. "foo.php?q=hello%20world" results in $_get['q'] having 'hello world' not 'hello%20world'

since you're using ecb mode iv ignored, fortunate since you'd need use same iv encrypt , decrypt.

as might failing - decrypted string padded block size might longer original string. can around passing along string length , using substr after decryption.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -