问题描述:

HI,

I am encrypting data with following PHP function:

$enc_data = mcrypt_encrypt(MCRYPT_3DES, $_key, $_data, MCRYPT_MODE_CBC, $_iv);

If I send the encrypted data per $_GET method, it’s not possible to decrypt it back because the $enc_data contains / and + signs:

QBlgcQ2+v3wd8RLjhtu07ZBd8aQWjPMfTc/73TPzlyA=

Btw. I am using this function to transfer data between .NET 2010 and PHP.

Any ideas how to solve this problem?


Solved!

if someone want to know how to use http_build_query()

<?php

echo "<a href='test.php?".http_build_query($enc_data)."'>test</a>";

$_data = str_replace("%3D", "=", $_GET['enc_data']);

$_data = str_replace("%2B", "+", $_GET['enc_data']);

$_data = str_replace("%2F", "/", $_GET['enc_data']);

echo $_data;

?>

网友答案:

Try using urlencode() or http_build_query() to make the encrypted string safe for transmission in a URL.

相关阅读:
Top