PHP中如何使用BLENC? [英] How to use BLENC in PHP?

查看:1104
本文介绍了PHP中如何使用BLENC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a testcode.php file need to encode:

<?php
    $hello = "Hello World!";
?>

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

And I created file encode.php to encrypt and test that file:

<?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时收到这些错误:

but I recevied these errors when I ran encode.php:


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

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


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

Fatal error: blenc_compile: Validation of script 'encrypt.php' failed, cannot execute. in C:\xampp\htdocs\PHPEncode\encode.php on line 14

帮我修复它,谢谢! :)

Help me fix it, thank you! :)

推荐答案

当blenc.key_file中有多个可重新分发的密钥时,BLENC有问题。请参阅我报告的 PHP bug#68490

BLENC has issues when there is more than one redistributable key in blenc.key_file. See PHP bug #68490 that I've reported.

此外,当您多次运行脚本时,可重新分发的密钥将在blenc.key_file中损坏。这是因为您附加到该文件,但是所有的密钥都保存在同一行上(同样的例子在php手册页上)。您应该将其更改为:

Also when you run your script multiple times, redistributable keys will get corrupted in blenc.key_file. This is because you are appending to the file, but all keys are saved on the same line (the same broken example is on php manual page). You should change it to:

file_put_contents($key_file, $redistributable_key."\n", FILE_APPEND);

您获得的第二个致命错误可能是因为损坏的blenc.key_file。

The second Fatal error you got was probably because of corrupted blenc.key_file.

这篇关于PHP中如何使用BLENC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆