首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用phpBolt用HTML文件加密PHP?

如何使用phpBolt用HTML文件加密PHP?
EN

Stack Overflow用户
提问于 2022-06-08 07:11:06
回答 1查看 293关注 0票数 0

我正在尝试使用.php加密phpBolt文件。当只使用PHP代码时,它就起作用了,但是如果它是HTML的混合,那么它就不能工作。

加密码:

代码语言:javascript
复制
<?php 

/**
 * src : source folder 
 * encrypted : Output folder
 */

$src      = 'src';
$php_blot_key = "kyc7fh";


/**
 * No need to edit following code 
 */

$excludes = array('vendor');

foreach($excludes as $key => $file){
    $excludes[ $key ] = $src.'/'.$file;
}

// $rec = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( $src ));
$rec  = new DirectoryIterator($src);
$require_funcs = array('include_once', 'include', 'require', 'require_once'); 


foreach ($rec as $file) {

    if ($file->isDir()) {
        $newDir  = str_replace( 'src', 'encrypted', $file->getPath() );
        if( !is_dir( $newDir ) ) mkdir( $newDir );
        continue;
    };

    $filePath = $file->getPathname();

    if( pathinfo($filePath, PATHINFO_EXTENSION) != 'php'  ||
        in_array( $filePath, $excludes ) ) {  
        $newFile  = str_replace('src', 'encrypted', $filePath );
        copy( $filePath, $newFile );
        continue;
    }

    $contents = file_get_contents( $filePath );
    $preppand = '<?php define("PHP_BOLT_KEY", "kyc7fh"); bolt_decrypt( __FILE__ , PHP_BOLT_KEY); return 0;
    ##!!!##';
    $re = '/\<\?php/m';
    preg_match($re, $contents, $matches ); 
    if(!empty($matches[0]) ){
       $contents = preg_replace( $re, '', $contents );
       ##!!!##';
    }
    /*$cipher   = bolt_encrypt( "?> ".$contents, $php_blot_key );*/
    $cipher   = bolt_encrypt( $contents, $php_blot_key );
    $newFile  = str_replace('src', 'encrypted', $filePath );
    $fp = fopen( $newFile, 'w');
    fwrite($fp, $preppand.$cipher);
    fclose($fp);

    unset( $cipher );
    unset( $contents );
}

$out_str       = substr_replace($src, '', 0, 4);
$file_location = __DIR__."/encrypted/".$out_str;
echo "Successfully Encrypted... Please check in <b>" .$file_location."</a></b> folder.";

此.php文件中不起作用的加密:

代码语言:javascript
复制
<html>
    <body>
        <h1>
            <?php 
                echo "Hello Sarbaz Ali !!!";
            ?>
        </h1>
    </body>
</html>

但是,当文件看起来像这样时,它就会工作:

代码语言:javascript
复制
<?php 
echo "<h1> Hello Sarbaz Ali !!! </h1>";
?>

我可以使用phpBolt加密上面的文件(使用HTML标记)吗?

EN

回答 1

Stack Overflow用户

发布于 2022-06-09 12:29:48

我建议在单独的文件中编写php代码,用php_bolt加密它,然后包含该文件usind包含函数。

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

https://stackoverflow.com/questions/72541466

复制
相关文章

相似问题

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