如何加密/解密 PHP GET 参数?

发布于 2024-11-27 19:24:44 字数 488 浏览 0 评论 0原文

我有一个常规请求,例如:

http://myserver.com/index.php?var1=85842.23&var2=212.235&name=Teddie&valid=1

我希望这些 $_GET 参数被加密为类似的东西(不是真实的,只是一个例子:)):

http://myserver.com/index.php?eParam=ks883d48223v2czozoz227272j2nn2dn2d2du3dh4hn4f4f4f4h3383xh8383s38s3j83sj8s3j92h2s89hs387h2s87hs287h2s87h2ui2c3iuhc287z9m2389f

当然,我需要在每一侧都有一个内置密钥,这将能够解密该信息。 有没有什么功能可以实现这一点? 我不关心客户端,因为它将是一个正在运行的应用程序,而不是网页或任何可以轻松进行逆向工程的东西。

谢谢 !

I have a regular request, for example:

http://myserver.com/index.php?var1=85842.23&var2=212.235&name=Teddie&valid=1

I would like those $_GET parameters be encrypted to something like (not real, just an example:)):

http://myserver.com/index.php?eParam=ks883d48223v2czozoz227272j2nn2dn2d2du3dh4hn4f4f4f4h3383xh8383s38s3j83sj8s3j92h2s89hs387h2s87hs287h2s87h2ui2c3iuhc287z9m2389f

Of course, I need a built in key on each side, that will be able to decrypt that info.
Is there any function that may render that possible ?
I am not concerned about the client side, as it will be a running application, not a webpage or anything that would be easily reverse-engineered.

Thanks !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梅窗月明清似水 2024-12-04 19:24:44

只需使用 SSL(即 HTTPS 而不是普通 HTTP)。然后,除了 DNS 查找域以及与域解析的 IP 地址建立的连接之外的所有内容都将被加密。

Just use SSL (i.e. HTTPS instead of plain HTTP). Then everything except the DNS look up for the domain and that a connection is made to the ip address that domain resolves to will be encrypted.

久而酒知 2024-12-04 19:24:44

实际上你可以这样做......你可以有一个加密/解密函数,包括给定参数的时间到期时间。我有一个脚本可以为我的网络系统执行此操作。而且你必须自己构建它,我不能公开我的安全脚本...但想法是这样的:

  1. 查找或构建一个加密/解密函数
  2. 添加日期和密码time 检查该函数,以便加密的字符串将过期
  3. 使用该函数加密传出的字符串
  4. 加密后,如果您使用 PHP,请 urlencode() 加密的字符串,以确保所有特殊字符在另一端接收后仍然存在它。
  5. 在另一端,执行 urldecode(),然后解密,然后传递值。

Actually you can do that... You can have an encrypt/decrypt function including a time expiry for the given parameter. I have a script that does that for my network systems. And you have to build that on your own, I can't go public with my security scripts... But here's the idea:

  1. Find or build an encryption/decryption function
  2. Add date & time checks for the function so that the encrypted string will expire
  3. Use that function to encrypt the outgoing string
  4. After encryption, if you're using PHP, urlencode() the encrypted string to make sure that all the special characters survives after the other end receives it.
  5. At the other end, perform a urldecode(), then decrypt it, then pass the value.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文