dpqvwgr74759 2012-08-24 03:04
浏览 57
已采纳

PHP:表单示例将加密查询字符串(GET)(数据隐藏而不是安全)

I intend to use GET for my form but would like to encrypt the values in the query string so that users are not able to change it. (not for security, but for data hiding purposes)

I came across a couple of websites which explained encryption, but it is not clear to me how to implement it once the user presses the submit button. Ex: http://myscriptlibrary.wordpress.com/2010/04/14/how-to-encrypt-query-string-in-php/

Is there an example which could show this?

Thanks.

  • 写回答

4条回答 默认 最新

  • douchensi8625 2012-08-24 04:02
    关注

    From my understanding of the link that you provided. You want to encrypt the GET variables, or at least obfuscate them.

    The best and easiest way that this could be done is using base64_decode/encode For example to encode the string you would do something like:

    $link = "http://www.example.com/?item=".urlencode(base64_encode("user-data"));
    

    $link would look something like http://www.example.com/?item=rklgEwkelnf%3D%3D, but to translate the seemingly garbled (base64ed) text into something usable you would use:

    foreach($_GET as $loc=>$item)
        $_GET[$loc] = base64_decode(urldecode($item));
    

    Then you can freely use the $_GET variable as you normally would.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?