(对不起,我的英语不好!)
为了保护我的 php 源代码,我只想用 ioncube 加密一个文件(例如function.php),然后我想在其他 php 文件中调用加密文件!(其他 php 文件将使用 mcrypt 函数加密。)
请看示例:
函数.php
<?php
// Only This file will be encrypted by the ionCube
function simple_encrypt($text)
{
$salt='whatever_you_want';
return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}
function simple_decrypt($text)
{
$salt='whatever_you_want';
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
function decrypt_and_run($text) {
eval (simple_decrypt($text));
}
?>
脚本1.php
<?php
include "function.php";
decrypt_and_run("Mz/PKIZDmo1/VW4BNXX2d+XQD2dx1aB9gnBj1hbGzVM=");
// Mz/PKIZDmo1/VW4BNXX2d+XQD2dx1aB9gnBj1hbGzVM= ~ echo "hello world1!";
?>
脚本2.php
<?php
include "function.php";
decrypt_and_run("oD3R8wPlUujQEkJfyPvTJOKek7MjzAuGBn+PfyssjZ4=");
// oD3R8wPlUujQEkJfyPvTJOKek7MjzAuGBn+PfyssjZ4= ~ echo "hello world2!";
?>
脚本3.php
<?php
include "function.php";
decrypt_and_run("vMef6WP9xm1nmsAYMSgxFRY2nhBPTNWog3rLOGhb69Y=");
// vMef6WP9xm1nmsAYMSgxFRY2nhBPTNWog3rLOGhb69Y= ~ echo "hello world3!";
?>
1) 这种方式能完全保护我所有的 PHP 源代码吗?(function.php, script1.php, script2.php, script3.php,...)
2) eval 函数在 ioncube 或 Zend Guard 中有效吗?
谢谢。