douxianxing5712 2015-02-04 08:09
浏览 67

加密URL中的PHP查询字符串值

Here is my question, i am trying to hide address value in URL

URL is something like this

example.com/linkdl/preview/index.php?address='http://mysiteexample.com'

I am trying to hide, ?address='http://mysiteexample.com' part, but i am not sure, what is best way

i have an idea to use base64_encode($adresa), but i am not sure will i have problems with (encoding/decoding special) characters in URL

$click = 'OtvoriProzor("'.$file_path.'&pk='.$sesija->pk.'&adresa='.base64_encode($adresa).
                    '&IDIstorijaElement='.$element->GetId().'", "Prevod", 700, 500);';

This is very insecure, can add some function for encryption, to encrypt and decrypt parametar, or will md5 help me here. Also should i use function url_decode url_decode instead?

  • 写回答

1条回答 默认 最新

  • dsvs50005 2015-02-04 08:16
    关注

    Since md5 is a hash algorithm, you won't be able to get back what you encoded. You can use base64 and urlencode to avoid problems with some characters:

    <?php
    $url = urlencode(base64_encode($adresa));
    ?>
    

    And you will decode it with:

    <?php
    $addr = base64_decode(urldecode($_GET['adresa']));
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'