PHP Velho Oeste 2024

blenc_encrypt

(PECL blenc >= 5)

blenc_encrypt Encripta un script PHP con BLENC

Descripción

blenc_encrypt ( string $plaintext , string $encodedfile [, string $encryption_key ] ) : string

Encripta el contenido del texto sin formato (plaintext) y lo escribe en un fichero codificado (encodedfile)

Parámetros

plaintext

El código fuente a encriptar. No necesita contener etiquetas PHP de abertura/cierre

encodedfile

El nombre del fichero donde BLENC grabará el código codificado.

encryption_key

La clave que utilizará BLENC para encriptar el texto. Si no se especifica BLENC creará una clave válida.

Valores devueltos

BLENC devolverá la clave redistribuible que debe salvarse dentro de key_file: el camino de acceso a key_file se especifica en el momento de ejecución con la opción blenc.key_file

Ejemplos

Ejemplo #1 Ejemplo con blenc_encrypt()

<?php

/* leer el código fuente PHP */
$source_code file_get_contents("my_source_to_protect.php");

/* crear la versión encriptada */
$redistributable_key blenc_encrypt($source_code"my_source_encoded.php");

/* leer cuál es el fichero key_file */
$key_file ini_get('blenc.key_file');

/* grabar la clave redistribuible */
file_put_contents($key_file$redistributable_keyFILE_APPEND);
?>

add a note add a note

User Contributed Notes 1 note

up
-4
user at grr dot la
7 years ago
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.
To Top