我有一个testcode.php文件需要编码:
<?php
$hello = "Hello World!";
?>
然后我创建了文件 encode.php 来加密和测试该文件:
<?php
/* read the PHP source code */
$source_code = file_get_contents("testcode.php");
/* create the encrypted version */
$redistributable_key = blenc_encrypt($source_code, "encrypt.php");
/* read which is the key_file */
$key_file = ini_get('blenc.key_file');
/* save the redistributable key */
file_put_contents($key_file, $redistributable_key, FILE_APPEND);
include 'encrypt.php';
echo $hello;
?>
但是我在运行 encode.php 时收到了这些错误:
Warning: blenc_compile: Validation of script 'encrypt.php' failed. MD5_FILE: 910e6a45f806ba3dc42830839971cb53 MD5_CALC: c38a6b2f389267a272ea656073a463ed in C:\xampp\htdocs\PHPEncode\encode.php on line 14
和
Fatal error: blenc_compile: Validation of script 'encrypt.php' failed, cannot execute. in C:\xampp\htdocs\PHPEncode\encode.php on line 14
帮我解决一下,谢谢! :)
最佳答案
当 blenc.key_file 中有多个可再发行 key 时,BLENC 会出现问题。参见 PHP bug #68490我已经报告了。
此外,当您多次运行脚本时,blenc.key_file 中的可再分发 key 将被损坏。这是因为您要附加到文件,但所有键都保存在同一行(相同的损坏示例在 php 手册页上)。您应该将其更改为:
file_put_contents($key_file, $redistributable_key."\n", FILE_APPEND);
您遇到的第二个 fatal error 可能是因为 blenc.key_file 损坏。
关于php - 如何在 PHP 中使用 BLENC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24159194/