简体   繁体   English

在PHP中反向混淆纯文本字符串URL

[英]Reverse obfuscating plain text string urls in PHP

I'm trying to figure out a way to program a function that will de-obfuscate a plain text url. 我正在试图找出一种方法来编写一个能够对纯文本URL进行去混淆的函数。

Something like this: 像这样的东西:

<input type="hidden" value="kjgajkwe@#jktGAkjgWjkajskd" name="obsfucatedString" />

Then in the processing of that form I want to De-Obsfucate it: 然后在处理那个表格的时候我想要去除它:

$url = deObfuscate($_POST['obsfucatedString']);
so $url would become something like:
$url = 'http://domain.com/filename.zip';

Is something like that even possible? 这样的事情甚至可能吗?

I'm trying to hide the url from plain programmer sight. 我试图隐藏普通程序员视线中的网址。

I guess I would need to write something that would obsfucate the string as well 我想我还需要写一些能阻碍字符串的东西

so 所以

$obsfucatedStringURL = obsfucate('http://domain.com/filename.zip');

Encrypt the URL with a password stored on the server (a good algorithm to use is AES), then decrypt it when you need to obtain the value. 使用存储在服务器上的密码加密 URL(使用的好算法是AES),然后在需要获取值时对其进行解密 A problem with this is that the encrypted string will not be composed of printable characters. 这样做的一个问题是加密的字符串不会由可打印的字符组成。 To get around this, use base64_encode() to convert the binary encoded string to printable characters that can be added as a value in the <input> field, then use base64_decode() to get back the original value on the server. 要解决此问题,请使用base64_encode()将二进制编码的字符串转换为可在<input>字段中作为值添加的可打印字符,然后使用base64_decode()获取服务器上的原始值。

There are many ways of encoding and reversing a plain text string. 编码和反转纯文本字符串的方法有很多种。 An simple way to obfuscate your string is by using the str_rot13 function once to encode and once again to decode ( note: this will not give you any cryptographic security ). 混淆字符串的一种简单方法是使用str_rot13函数进行一次编码并再次进行解码( 注意:这不会为您提供任何加密安全性 )。 I'd suggest encrypting using AES using a secret stored on the server to encrypt and decrypt. 我建议使用AES加密,使用存储在服务器上的秘密进行加密和解密。 The following thread's answer defines functions for encrypting/decrypting that you can use. 以下线程的答案定义了您可以使用的加密/解密功能。

PHP AES encrypt / decrypt PHP AES加密/解密

Another approach that might be worth considering vs. obfuscation is to store the URL server side as part of the user's session or persisted in a database. 另一种可能值得考虑与混淆的方法是将URL服务器端存储为用户会话的一部分或者保存在数据库中。 Then instead of sending an obfuscated string down, use a key that performs a lookup to retrieve the URL. 然后,不是发送混淆的字符串,而是使用执行查找的密钥来检索URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM