php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68490 Blenc compile warning when running encrypted script with multiple redist keys
Submitted: 2014-11-24 11:05 UTC Modified: 2017-01-10 08:32 UTC
Votes:8
Avg. Score:4.9 ± 0.3
Reproduced:5 of 6 (83.3%)
Same Version:2 (40.0%)
Same OS:1 (20.0%)
From: czarek dot tomczak at gmail dot com Assigned:
Status: Suspended Package: BLENC (PECL)
PHP Version: 5.4.35 OS: Windows 7 64bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 - 3 = ?
Subscribe to this entry?

 
 [2014-11-24 11:05 UTC] czarek dot tomczak at gmail dot com
Description:
------------
I am encrypting two php scripts and saving redistributable keys to ".blenc_keys" file. When running the first script (blenc_myscript_encoded.php) everything works fine, but when running the second script (blenc_myscript2_encoded.php) I get warning:

    Warning: blenc_compile: Validation of script 'C:\phpdesktop\phpdesktop-chrome\www\blenc_myscript2_encoded.php' failed. 
    MD5_FILE: c269d23aa66d05474d7b408484c74c1d MD5_CALC: bbf95ab01978895e216cc1d6ed4ccaea in Unknown on line 0

The second script executes fine after that warning is shown.

The blenc_encode.php example encrypts php script and saves redistributable key. There is also blenc_encode2.php that does the same but for blenc_myscript2.php / blenc_myscript2_encoded.php.

--------------------------------------------------------------------------------
blenc_encode.php
--------------------------------------------------------------------------------
<?php
error_reporting(-1);
$source_code = file_get_contents("blenc_myscript.php");
$source_code = preg_replace('#^<'.'\?php\s+#', '', $source_code);
$source_code = preg_replace('#\s+\?>\s*$#', '', $source_code);
$redist_key = blenc_encrypt($source_code, "blenc_myscript_encoded.php");
$key_file = ini_get('blenc.key_file');
file_put_contents($key_file, $redist_key."\n", FILE_APPEND);
?>

--------------------------------------------------------------------------------
blenc_myscript.php
--------------------------------------------------------------------------------
<?php
print("Printing a secret string: XuXuXaaa");
?>

--------------------------------------------------------------------------------
blenc_myscript2.php
--------------------------------------------------------------------------------
<?php
print("Printing a secret string: XuXuXaaa");
?>

--------------------------------------------------------------------------------
.blenc_keys
--------------------------------------------------------------------------------
s6VQnAHX/VXaOLjkks6eHrecTLFDmJn1FHXWo/5BuW4=
QOAqS7SNr2+yDES7EOY0hMPOd1TxCPB/kNTpUfcNzzE= 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-24 11:24 UTC] czarek dot tomczak at gmail dot com
On blenc_encrypt() manual page (http://php.net/manual/en/function.blenc-encrypt.php) there is an error in Example #1. Redistributable keys are saved on the same line, but they should be seperated by new line character. This line:

    file_put_contents($key_file, $redistributable_key, FILE_APPEND);

Should be changed to:

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

People are getting into troubles because of that when script is run multiple times. Blenc key file is getting corrupted and results in a fatal error:

    Fatal error: blenc_compile: Validation of script 'encrypt.php' failed,
    cannot execute. in C:\xampp\htdocs\PHPEncode\encode.php on line 14
 [2015-03-18 06:52 UTC] ameerhamza dot tariqjaveed at gmail dot com
I used your encoder file but i get this error
Fatal error: blenc_compile: Validation of script 'C:/xampp/htdocs/test/encrypt.php' failed, cannot execute. in Unknown on line 0

----------------------------------------------------------------------
encoder.php
----------------------------------------------------------------------

<?php
error_reporting(-1);
$source_code = file_get_contents("encrypt.php");
$source_code = preg_replace('#^<'.'\?php\s+#', '', $source_code);
$source_code = preg_replace('#\s+\?>\s*$#', '', $source_code);
$redist_key = blenc_encrypt($source_code, "blenc_myscript_encoded.php");
$key_file = ini_get('blenc.key_file');
file_put_contents($key_file, $redist_key."\n", FILE_APPEND);
?>
 [2017-01-10 08:32 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-01-10 08:32 UTC] kalle@php.net
I'm suspending the reports for BLENC as it doesn't seem to have stalled (looking at both repositories I could find on git.php.net and github) and it does not seem compatible with any currently supported version of PHP either. Please unsuspend in case someone takes over this extension
 [2017-01-10 08:32 UTC] kalle@php.net
I'm suspending the reports for BLENC as it doesn't seem to have stalled (looking at both repositories I could find on git.php.net and github) and it does not seem compatible with any currently supported version of PHP either. Please unsuspend in case someone takes over this extension
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 15:01:28 2024 UTC