首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误验证编码脚本

错误验证编码脚本
EN

Stack Overflow用户
提问于 2015-02-15 17:18:31
回答 1查看 808关注 0票数 1

我在试这个

代码语言:javascript
复制
<?php
    /* read the PHP source code */
    $source_code = file_get_contents("hello.php");

    $source_code = preg_replace('#^<\?php\s+#', '', $source_code);
    $source_code = preg_replace('#\s+\?>\s*$#', '', $source_code);

    /* create the encrypted version */
    $redistributable_key = blenc_encrypt($source_code, "encrypt.php", "my_fixed_password");

    $key_file = __DIR__ ."\keys"; 

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

    include 'encrypt.php';
    echo $hello;
?>

hello.php

代码语言:javascript
复制
<?php 

$hello = "Ciao";

我犯了这个错误

代码语言:javascript
复制
PHP Fatal error:  blenc_compile: Validation of script 
'encrypt.php' failed, cannot execute.

请注意:

  1. 创建了密钥文件,我已经使用了'\n‘修复
  2. 我替换了<?php?>,因为另一个堆栈溢出问题告诉我这是个问题
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-15 22:56:28

代码语言:javascript
复制
<?php
    $file_name = basename($file);

    $unencrypted_key = = md5(time());

    $source_code = file_get_contents($file);

    //This covers old-asp tags, php short-tags, php echo tags, and normal php tags.
    $contents = preg_replace(array('/^<(\?|\%)\=?(php)?/', '/(\%|\?)>$/'), array('',''), $source_code);

    $html .= "<br> BLENC blowfish unencrypted key: $unencrypted_key" . PHP_EOL;
    $html .= "<br> BLENC file to encode: " . $file_name . PHP_EOL;

    //file_put_contents('blencode-log', "---\nFILE: $file_name\nSIZE: ".strlen($contents)."\nMD5: ".md5($contents)."\n", FILE_APPEND);

    $redistributable_key = blenc_encrypt($contents, TARGET_DIR . '/blenc/' . $file_name, $unencrypted_key);
    $html .= "<br> BLENC size of content: " . strlen($contents) . PHP_EOL;

    /**
    * Server key
    * key_file.blenc
    */
    file_put_contents(TARGET_DIR . '/blenc/' . 'key_file.blenc', $redistributable_key . PHP_EOL);
    $html .= "<br> BLENC redistributable key file key_file.blenc updated." . PHP_EOL;
    exec("cat key_file.blenc >> /usr/local/etc/blenckeys");
?>

https://github.com/codex-corp/ncryptd/blob/master/app/controllers/MagicalController.php#L479

你应该把钥匙放在

短键

服务器上的文件

注意:如果存在“脚本验证”问题,有时需要重新加载apache。

How to use BLENC in PHP?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28528797

复制
相关文章

相似问题

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