سؤال

I utilise RSA for crypting some data and I wish to pass data to my server as a GET link in this way:

myserver.ext/index.php?data=Âhå/2#ÛI§cw¦»L¸ÙvóìßKßàë%`N5 Ï'üQn6ÕYì&7ï,Î}:i!öççk\¶Z:Ò/MTÚFÿ*ßÕ®ØÒ¿¢y:ïM&CçëöѤÛ5Âÿ­QöÎÙ Ð=Páë*¹-fð

If I type 'enter' on this link the borwser adds special characters (to purify link I think) and If I print content of 'data' with

echo $_GET['data'];

but php cuts the content. Is there a way to solve this issue?

Thanks.

Edit: I tried with encoding url but RSA decryption doesn't works. The strange thing is that in my local server (LAMPP) it perfectly works, but not on remote server.

هل كانت مفيدة؟

المحلول 2

you can use these functions to encrypt/decrypt your data

    function rsa_encrypt($yourPublickey, $message)
    {
        $rsa = new Crypt_RSA();
        $rsa->loadKey($yourPublickey);
        $encrypted = urlencode(base64_encode($rsa->encrypt($message)));

        return $encrypted;
    }

    function rsa_decrypt($yourPrivatekey, $cryptedData)
    {
        $rsa = new Crypt_RSA();
        $rsa->loadKey($yourPrivatekey);
        $decrypted = $rsa->decrypt((base64_decode($cryptedData)));

        return $decrypted;
    }

نصائح أخرى

Use either urlencode or base64_encode, and decode accordingly.

For passing slashes by url without changing it into new action or folder you must convert all the "/" to some specific pattern I used "---" and in your code convert all the "---" to "/" and you get your value in the get arguments.

like:

var temp = replaceAll('/','---',your_link);

function replaceAll(find, replace, str) {
 return str.replace(new RegExp(find, 'g'), replace);
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top