Question

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!

Was it helpful?

Solution

Agree with user2864740

Or you can use Base32 since you have only 50.

OTHER TIPS

Well, perhaps php bson. Read more at BSON. Its popularised or used by MongoDB but maybe check it out for alternatives to basexxx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top