You are on page 1of 5

ionCube PHP Encoder 9.

Examples

ioncube.com

ionCube and the ionCube logo are registered trademarks of ionCube Ltd.
ionCube PHP Encoder 9.0 Examples https://www.ioncube.com/php_encoder.php

Example Projects
This folder contains a sample PHP project in the MyProject folder, and several ionCube PHP Encoder Project
(.iep) files.

You can open a project file in several ways:

• Double clicking the .iep file.


• Right clicking in Explorer and selecting Encode Project.
• Starting the PHP Encoder GUI and opening the project file from there.

To view the Target Folder and encoded files use the menu option:

Project > Browse Target Folder or use F9

The project files demonstrate the use of various features described below. Each project file encodes the
MyProject source project folder into the encoded-projects folder within Examples.

Example - Basic Encoding


This example shows encoding a small project with some files encoded, some just copied and some
excluded.

1. In the Project Settings you will see on the Source Tab that a Source Folder has been set. This is
where the files you want to encode are located.

2. On the Target Tab the Target Folder is within encoded-projects in the folder Example - Basic
Encoding.

3. On the Source Tab the PHP source language is set to 5.6.

4. The index.php and functions.inc are being encoded as indicated by the yellow key
icon.

5. The config.inc file is set to be copied to the Target Folder rather than encoded.

6. The LOCAL README.txt file has been excluded, as indicated by greyed out file name.

7. Click the play button to start the encoding process.

8. Open the Target Folder Example - Basic Encoding where you can view the
index.php file in a text editor to see that it is encoded.
ionCube PHP Encoder 9.0 Examples https://www.ioncube.com/php_encoder.php

Example – Licensing
(Only available in Pro, Cerberus and Evaluation versions)

This example shows licensing an encoded file using an external license file, with an expiry time of the
encoded file.

The Source Tab settings are the same as the example above. The Target Folder is now set to Example -
Licensing. The basic encoding settings will be the same as above.

1. On the Restrictions Tab in Project Settings the Encoded files require a license file checkbox is
checked. The license file lic.txt requires the passphrase mypassphrase.

2. In License Settings the file expiry is set to 5 minutes, the license passphrase is the same as before
and the output path is set to the Target Folder Example – Licensing.

3. Click the play button to start the encoding process.

4. Use Licensing > Create License or use F6 to open the Create License dialogue.

5. In Create License click Generate License.

6. Open the Target Folder Example - Licensing where you can view the index.php file
in a text editor to see that it is encoded.
ionCube PHP Encoder 9.0 Examples https://www.ioncube.com/php_encoder.php

Example - Dynamic Keys


This example shows the use of the dynamic keys feature, using a function as the key generator located in a
separate file to the one being encoded.

For this example the Source Folder has been adjusted to use new files which make use of a dynamic key.
The Target Folder is now set to Example - Dynamic Keys. The encoding settings will be the same as
in the 'Basic Encoding' example above.

1. Open the index.php file found in MyProjects - Dynamic Keys in a text editor to
view the code. The function myfn() will be encoded using the dynamic key specifier:

// @ioncube.dk keyfunction() -> "THE KEY VALUE" RANDOM

The function keyfunction() is defined in the functions.inc file.


The key specifier causes the code for the function that follows to be encrypted with a random
choice of cryptographically secure encryption algorithm. The encryption key is "THE KEY
VALUE", and at runtime, the function keyfunction() will be called to produce the
required key.
The function myfn() will only run if the returned value of keyfunction() equals "THE
KEY VALUE".

2. Click the play button to start the encoding process. The summary output will show any dynamic
keys detected and used.

3. Open the Target Folder Example - Dynamic Keys where you can view the index.php
file in a text editor to see that it is encoded.

This is true encryption and is stronger than the common idea of what encryption is since the key does not
exist until the function is run. Dynamic key functions can be as complex as you like and you can use multiple
keys giving unlimited protection. More information can be found in the user guide:
http://www.ioncube.com/sa/USER-GUIDE.pdf

Dynamic Keys is a feature available with Version 9 Encoder and PHP source language 5.3 or higher.
ionCube PHP Encoder 9.0 Examples https://www.ioncube.com/php_encoder.php

Best Practice Guide


• The best dynamic key generators are complex. The best dynamic key generators will depend on a
number of factors. So, you could have the following within a function that generates a dynamic key:

$fnder = new $GLOBALS['class_name']($a,$b,$c);

There you will be using a class to help generate the dynamic key and the name of that class
comes from a global variable.
• The External Key feature is useful on your own website where the key can be stored anywhere. For
example the key could be the path to a file stored outside the protected application.
• Use Obfuscation Settings for additional protection of identifiers. This makes it more difficult to
reverse engineer readable code.
• You can automate the licensing of your product by using the make_license application.
• Custom key/value properties can be added to licenses, which can be useful if creating your own
licensing or security checks.

We hope you enjoy using our product. You can contact us at https://support.ioncube.com, if you have any
questions or require assistance.

(c) ionCube Ltd. 2016

You might also like