php - 如何在 PHP 中使用 BLENC?

标签 php encryption

我有一个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/

相关文章:

php - 插入 mysql (php) 时删除数字

java - CipherInputStream 和 CipherOutputStream 不生成文件

algorithm - 混淆 ID

javascript - 将值从 javascript 传递到 PHP(使用隐藏字段)

PHP & MySQL 地理距离计算

php - 是否可以改变 PHP 的 print_r 函数的行为

php - MailChimp 支持 : the final "welcome" email with the link to unsubscribe

javascript - 如何使用aes-128-cbc算法实现CryptoJS解密?

javascript - 使用 CryptoJS 更改 key

algorithm - AES 使用数学符号