2016-08-02 86 views
-2

在php中有很多代码保护库,但是他们需要安装额外的php模块,这是我无法承受的,因为应用程序将在我没有的服务器上运行。所以我想我可以自己做。PHP代码保护库

我想要做什么:

$source = file_get_contents("encryptedPhpFile.php"); 
$source = decrypt($source, "mySecretKey"); 
//$source now contains decrypted source code which needs to be included 

//I cant use eval($source); because that code also contains 
//html/css/opening and closing php tags ... which eval() does 
//not know how to render 

//I cant write the source into temporary file and then include 
//that file because as soon as I write decrypted source to a disk, 
//it is exposed and it can be copyed 

我能做些什么?有什么建议么?

+2

没什么可靠的。您唯一的选择是评估或编写一个包含源文件的文件。但是,这不以任何方式“安全”。在'decrypt'调用之后,所有人都必须做'echo $ source',并且他们有你的全部源码。 –

+1

标题并不能真正恰当地描述问题。你能改善它吗? –

+2

为什么你需要“保护”你的代码呢?除非整个服务器受到攻击,否则人们无法下载您的php脚本源,此时我怀疑任何保护措施都有帮助。 –

回答

6

这些库是模块的原因。您将无法在“代码空间”中完全模拟它们。你的尝试将是笨拙的(不是你的错),并使你的代码库不那么令人愉快/可维护。

您应该专注于获得安装它们的权限,迁移到允许您控制服务器到有用程度的主机,或者启动并运行自己的服务器。