Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use BLENC in PHP?

Tags:

php

encryption

I have a testcode.php file need to encode:

<?php
    $hello = "Hello World!";
?>

And I created file encode.php to encrypt and test that file:

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

but I recevied these errors when I ran 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

and

Fatal error: blenc_compile: Validation of script 'encrypt.php' failed, cannot execute. in C:\xampp\htdocs\PHPEncode\encode.php on line 14

Help me fix it, thank you! :)

like image 775
Hoan Tran Avatar asked Jun 11 '14 09:06

Hoan Tran


People also ask

What does mix blend mode do?

The mix-blend-mode CSS property sets how an element's content should blend with the content of the element's parent and the element's background.

How do you blend two images in CSS?

Background blend mode with two images It's as easy as adding two background images in the CSS declaration. The next choice is to have a background color (or not). If you do not want a background color, this can be removed and the images will blend together depending on the blend mode that you choose.

What is blend pass through CSS?

When pass-through blending is used on a group, the rendered result is as if the group didn't exist. The group is not merged into a single image before being blended with everything underneath. This means the group is just being used for layer panel organisation, and not altering the compositing behaviour at all.

What is PHP mage?

Magallanes is a deployment tool made with PHP and for PHP applications, it's quite simple to use and manage. Just like typing bin/mage deploy production. If you have used Magallanes, and you found it useful, then let's grab some coffee! Buy me a coffee.


2 Answers

BLENC has issues when there is more than one redistributable key in blenc.key_file. See PHP bug #68490 that I've reported.

Also when you run your script multiple times, redistributable keys will get corrupted in blenc.key_file. This is because you are appending to the file, but all keys are saved on the same line (the same broken example is on php manual page). You should change it to:

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

The second Fatal error you got was probably because of corrupted blenc.key_file.

like image 141
Czarek Tomczak Avatar answered Oct 26 '22 02:10

Czarek Tomczak


;) just delete "<?php ?>" in your page *.php compiled this not with "<?php and ?>"

just $hello = "Hello World!";

and is ok :) !

like image 1
Darksynx Avatar answered Oct 26 '22 01:10

Darksynx