如何在PHP中使用BLENC?

Hoa*_*ran 7 php encryption

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

<?php
    $hello = "Hello World!";
?>
Run Code Online (Sandbox Code Playgroud)

我创建了文件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;
?>
Run Code Online (Sandbox Code Playgroud)

但是当我运行encode.php时,我收到了这些错误:

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

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

帮我解决一下,谢谢!:)

小智 0

您需要指定名为或 via的blenc.key_filein变量的完整位置,不可能在运行时设置(此时密钥文件已被读取)。php.iniblenc.key_file.htaccessini_set()

.htaccess例子:

php_value blenc.key_file /path/path/path/key_file.blenc
Run Code Online (Sandbox Code Playgroud)

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

$private_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxVCHANGEME";
$redistributable_key = blenc_encrypt($source_code, "encrypt.php", $private_key);
Run Code Online (Sandbox Code Playgroud)