Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a page that receive via GET a base64 encoded data, it print data in an input hidden and it pass via get to another page.

The problem is this: when i pass

"Peuq/0X4XhFV+XNa8T06qFrP8lRadORUQBGJ1w6D4m33Jaqx/skKDEJIxjldBrcklboL/uB4C65cjz3BHMPmd3moEJ4GTK5k5Jwf9Ny4BA467bwgeaHJuOS+CjwFlIOzrhSWHTMVl4zWVvwMauuFAjhuMjOOj0/X5L12IcwGTTqLgHo"

via GET it becomes

"Peuq/0X4XhFV XNa8T06qFrP8lRadORUQBGJ1w6D4m33Jaqx/skKDEJIxjldBrcklboL/uB4C65cjz3BHMPmd3moEJ4GTK5k5Jwf9Ny4BA467bwgeaHJuOS CjwFlIOzrhSWHTMVl4zWVvwMauuFAjhuMjOOj0/X5L12IcwGTTqLgHo"

...so openssl can't work. How can I solve it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

Base64 can output + signs which are interpreted as spaces when sent in the URL. You can use urlencode to mitigate this:

<?php
$base64_data = $_GET['base64'];
$url_data = urlencode($base64_data);
$field_data = htmlspecialchars($url_data);
printf('<input type="hidden" value="%s" name="pass-it-on">', $field_data);
?>

On page two:

<?php
$base64_data = $_GET['pass-it-on'];
$real_data = base64_decode($base64_data);
?>

Note that there's no need to decode the htmlspecialchars ur urlencode calls since this is done automatically.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...