khaledz370/kencrypt

Kencrypt is a PHP extension that securely decrypts and executes encrypted PHP code at runtime, protecting source code during transmission and execution.

dev-main 2025-05-03 05:41 UTC

This package is auto-updated.

Last update: 2025-05-03 12:33:35 UTC


README

The Kencrypt PHP extension securely decrypts and executes encrypted PHP code at runtime, protecting source code during transmission and execution, and can be used with supported PHP versions.

⚠️ Note: This extension is compatible only with Thread Safe (TS) builds of PHP.

📦 Extension Files Provided

The following DLL files are included for compatibility with specific PHP versions:

  • php_kencrypt_8.2.dll
  • php_kencrypt_8.3.dll
  • php_kencrypt_8.4.dll

🔧 Installation Instructions

1. Select the Correct DLL

Choose the DLL that matches your PHP version:

  • PHP 8.2 → php_kencrypt_8.2.dll
  • PHP 8.3 → php_kencrypt_8.3.dll
  • PHP 8.4 → php_kencrypt_8.4.dll

To verify your PHP version and thread safety mode, run:

php -i | findstr "Thread"

Look for:

Thread Safety => enabled

2. Move the DLL File

Copy the correct DLL file into your PHP ext directory. For example:

C:\your_php_directory\ext```

### 3. Enable the Extension

Edit your `php.ini` file and add the following line:

```ini
extension=php_kencrypt_8.x.dll

Replace 8.x with the actual version of PHP you are using.

4. Restart Your Server

After editing php.ini, restart your PHP server (e.g., Apache or Nginx) using any local server runner like XAMPP or similar.

5. Confirm the Extension is Loaded

You can confirm the extension is active by running:

php -m

Or by accessing a phpinfo() page in your browser and checking that kencrypt is listed.

🚀 Testing the Extension

Step 1: Run encrypt.php

Open the encrypt.php file in your browser using any local PHP server:

http://localhost/kencrypt/encrypt.php

The page will only work if the Kencrypt extension is successfully loaded.

🔐 Using the Extension

Step 1: Add Your Encryption Key

Before generating the encrypted code, you need to specify your encryption key. Open the index.php, copy the sample code provided, and paste it into the encrypt.php input field.

Make sure to add your encryption key, like so:

$encryption_key = 'your_encryption_key_here'; // Define your key here

Step 2: Encrypt

Click the Encrypt button. You will receive the encrypted output.

Step 3: Use Encrypted Output

Take the encrypted string and use it in your PHP code like this:

$code = 'your_encrypted_code_here';
$userKey = 'your_user_key_here'; // Use your encryption key here
exc_kencrypt($code, $userKey);

Step 4: Test with test.php

Paste the code snippet above into test.php and run it to confirm everything is working properly.

⚠️ Important Notice

Do not use this extension to encrypt very large files. The extension has not been tested with large file sizes, and it may cause issues. If you need to encrypt a large file, consider encrypting the file in smaller chunks. To do this, you can copy a portion of the code and call exc_kencrypt() multiple times to encrypt smaller sections of the file, thus reducing the overall encryption length.

✅ Requirements

  • PHP 8.2, 8.3, or 8.4
  • Thread Safe (TS) PHP build
  • Local server (e.g., XAMPP or similar)
  • Corresponding version of php_kencrypt_*.dll

🛠 Troubleshooting

  • Ensure your PHP build is Thread Safe
  • Use the correct DLL for your PHP version
  • Verify that the extension is listed in your php.ini
  • Restart the server after enabling the extension
  • Use phpinfo() or php -m to verify the extension is loaded