-1

所以我不确定这是否可能,但我们开始吧。我希望能够创建一个正常运行但不可读的字符串。例如:

$password = "//312(!@#()";

然后我可以去类似的东西。

if($input == $password) {

}

无论如何我可以做到这一点吗?我可能正在通过我的脑海中的一个洞说话,但任何关于这个主题的帮助都会有所帮助。

4

2 回答 2

0

您可以散列字符串:

$pw_hash = "098f6bcd4621d373cade4e832627b4f6" //is the hash of "test"

if ($pw_hash == md5($variable)){
    //now you know, the variable is "test", 
    //without writing it plaintext in the sourcecode.
}

但是搜索哈希。有比 md5 更好的选择。也可以在谷歌上搜索“salt”并了解“散列”和“加密”之间的区别。

于 2013-01-18T10:58:39.373 回答
0

从您的评论中,我相信您想在部署应用程序时隐藏您的 php 源代码。我看到许多开发人员通常使用将base64_encode原始 PHP 代码编码为单个字符串并eval(base64_decode($str))在他们部署的包中使用。

但是,这种方式只对普通用户有用,我们总是可以使用http://perishablepress.com/tools/decoder/之类的在线工具(或编写自己的函数)来获取原始源:)

于 2013-01-18T11:06:49.173 回答