dtpd58676 2015-05-28 12:57
浏览 255

如何通过post或get方法对url进行编码并解码url

I can easily encode and decode the URL when the actual string is not transfer through the POST or GET url only work with static string passed in the function.

I need to send some encoded string with some static information like

http://somedomain.com/testfolder/test.php?tracking_url='someotherdomain.com?id=10&test_id=50'&click_id=60

i use the following code like as below

<?php


  class test{

  public static function simple_encrypt($text)
    {
          $salt ='whatever_you_want';
        return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
    }

  public static function simple_decrypt($text)
    {
          $salt ='whatever_you_want';
        return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
    }
  }


 echo $test =test::simple_encrypt("http://somedomain.com/testfolder/test.php?tracking_url='someotherdomain.com?id=10&test_id=50'&click_id=60");
 echo "<br/>";

echo test::simple_decrypt($test);
?>

the above code is working perfect if i pass the encoded string as a static like
echo test::simple_decrypt($test); i got the the sting back : http://somedomain.com/testfolder/test.php?tracking_url='someotherdomain.com?id=10&test_id=50'&click_id=60

but i need to get the encoded string through the url than i need to fetch the tracking_url and encoded string.

thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题
    • ¥20 RL+GNN解决人员排班问题时梯度消失
    • ¥60 要数控稳压电源测试数据
    • ¥15 能帮我写下这个编程吗
    • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路