当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Sending data encrypted with MCRYPT_3DES as a URL parameter

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: