blenc_encrypt
(PECL blenc >= 5)
blenc_encrypt — Encrypt a PHP script with BLENC.
Description
$plaintext
, string $encodedfile
[, string $encryption_key
] )Encrypt the plaintext content and write it into encodedfile
Parameters
-
plaintext
-
A source code to encrypt. Does not need to contain opening/closing PHP tags
-
encodedfile
-
The filename where BLENC will save the encoded source.
-
encryption_key
-
The key that BLENC will use to encrypt plaintext content. If not given BLENC will create a valid key.
Return Values
BLENC will return the redistributable key that must be saved into key_file: the path of key_file is specified at runtime with the option blenc.key_file
Examples
Example #1 blenc_encrypt() example
<?php
/* read the PHP source code */
$source_code = file_get_contents("my_source_to_protect.php");
/* create the encrypted version */
$redistributable_key = blenc_encrypt($source_code, "my_source_encoded.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);
?>
Коментарии
as [b]encryption_key[/b] need not key, but key file. examle:
[code]
<?php
blenc_encrypt($source_code, "my_source_encoded.php", 'IMyxRIF3w+oTRCf4VOnRvw=='); // invalid
blenc_encrypt($source_code, "my_source_encoded.php", file_gets_contents(ini_get('blenc.key_file'))); // invalid
blenc_encrypt($source_code, "my_source_encoded.php", ini_get('blenc.key_file')); //valid
?>
[/code]
for encoding key file may have more that 1 key. code will be run, but php return warning if valid key not first.