簡體   English   中英

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

[英]How to encrypt PHP with HTML file using phpBolt?

我正在嘗試使用 phpBolt 加密 .php 文件。 當只使用 PHP 代碼時它可以工作,但是如果它是 HTML 的混合則它不工作。

加密代碼:

<?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.";

加密在 this.php 文件中不起作用:

<html>
    <body>
        <h1>
            <?php 
                echo "Hello Sarbaz Ali !!!";
            ?>
        </h1>
    </body>
</html>

但是當文件看起來像這樣時,它將起作用:

<?php 
echo "<h1> Hello Sarbaz Ali !!! </h1>";
?>

我可以使用 phpBolt 加密上述文件(帶有 HTML 標簽)嗎?

我建議將您的 php 代碼編寫在單獨的文件中,使用 php_bolt 對其進行加密,然后使用 php 包含函數包含該文件。

取決於基於 phpBolt 編碼器的Laravel-Source-Encrypter包:

刀片文件不是真正的 PHP 文件。 它們主要包含 HTML 和 CSS 代碼。

Blade 文件是 HTML 代碼加上 PHP 代碼,所以加密 HTML 代碼沒有意義,因為里面沒有邏輯。

phpBolt 只能解密並執行 php 文件(作為一個不可分割的步驟),不可能再次解密它們。

你還可以看到: 你能告訴我我們如何加密刀片文件嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM