I need to encode a string with Javascript and would like to decode it with PHP (code below).
Unfortunately the usual functions like urlencode()
, encodeURIComponent()
, etc. will not work in this case, because my PHP framework interprets slashes /
as separators, even the encoded ones.
The string length is in a range of 1 to 50 chars. Encrypting isn't the focus, rather performance.
Does anyone know a good alternative to base64
?
Javascript
var str = doEncode("I'm a String with special chars!§$%&/()");
window.location = "http://localhost/script.php?encoded_string=" + str;
PHP
$str = doDecode($_GET["encoded_string"]);
echo $str; // I'm a String with special chars!§$%&/()
Thanks in advance!