首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在PHP中使用BLENC?

如何在PHP中使用BLENC?
EN

Stack Overflow用户
提问于 2014-06-11 09:23:17
回答 4查看 9.3K关注 0票数 7

我有一个需要编码的testcode.php文件:

代码语言:javascript
复制
<?php
    $hello = "Hello World!";
?>

我创建了encode.php文件来加密和测试该文件:

代码语言:javascript
复制
<?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时,我重述了这些错误:

警告: blenc_compile:脚本'encrypt.php‘的验证失败。MD5_FILE: 910e6a45f806ba3dc42830839971cb53 MD5_CALC: c38a6b2f389267a272ea656073a463ed in C:\xampp\htdocs\PHPEncode\encode.php,第14行

致命错误: blenc_compile:对脚本'encrypt.php‘的验证失败,无法执行。在第14行的C:\xampp\htdocs\PHPEncode\encode.php中

帮我修一下,谢谢!)

EN

回答 4

Stack Overflow用户

发布于 2014-11-24 11:16:43

当blenc.key_file中有多个可再分发密钥时,BLENC会出现问题。请看我报告的PHP #68490

而且,当您多次运行脚本时,可重新分发的密钥将在blenc.key_file中损坏。这是因为您要附加到文件中,但是所有的键都保存在同一行中(同一已损坏的示例在php手动页面上)。你应该把它改为:

代码语言:javascript
复制
file_put_contents($key_file, $redistributable_key."\n", FILE_APPEND);

第二个致命错误可能是由于损坏的blenc.key_file造成的。

票数 2
EN

Stack Overflow用户

发布于 2014-12-16 10:44:27

)只需删除页面中的"<?php ?>“,*.php就会编译它,而不是用"<?php and ?>

$hello =“你好世界!”;

而且很好:)!

票数 1
EN

Stack Overflow用户

发布于 2014-09-11 12:00:35

您需要在名为blenc.key_file或通过.htaccessphp.ini变量中指定ini_set()的完整位置,不可能在运行时使用ini_set()设置(此时密钥文件已经读取)。

.htaccess示例:

代码语言:javascript
复制
php_value blenc.key_file /path/path/path/key_file.blenc

每次加密文件时,都会生成一个新的$redistributable_key!您必须将所有密钥包含在密钥@中,或者在所有加密中使用固定(私有)加密密钥:

代码语言:javascript
复制
$private_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxVCHANGEME";
$redistributable_key = blenc_encrypt($source_code, "encrypt.php", $private_key);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24159194

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档