HObfus v2.04
First Example

This first example will walk you through the process for setting up HObfus in a PHP page. We will explain how to set up HObfus in a PHP page so the HTML code generated by the PHP page gets obfuscated when opened in a browser. We will use the following PHP page as an example to show how to use HObfus.

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>My PHP Page</title>
	</head>
	<body>
		<?php echo "The current time is ".date("Y-m-d H:i:s"); ?> 
	</body>
</html>
1.  Specify code to obfuscate

To specify the code that you want to obfuscate, enclose it inside <?php HObfus_begin(); ?> and <?php HObfus_end(); ?>. In this example, we will obfuscate the entire page, so insert <?php HObfus_begin(); ?> and <?php HObfus_end(); ?> at the beginning and the end of the file, respectively, as shown below.

<?php HObfus_begin(); ?>
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>My PHP Page</title>
	</head>
	<body>
		<?php echo "The current time is ".date("Y-m-d H:i:s"); ?> 
	</body>
</html>
<?php HObfus_end(); ?>

The HTML code generated between <?php HObfus_begin(); ?> and <?php HObfus_end(); ?> will be obfuscated when the PHP page is opened in a browser.

2.  Include HObfus.inc.php

Before testing the PHP page, there is one more thing to be done. In the previous step, you added two functions: HObfus_begin() and HObfus_end() to the PHP page. These functions are declared in the file, hobfus/HObfus.inc.php, which you installed in the installation page. To make the functions available to your PHP page, you need to include hobfus/HObfus.inc.php using the require_once() function, like shown below.

<?php require_once("PATH-TO-HObfus.inc.php"); ?>
<?php HObfus_begin(); ?>
<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>My PHP Page</title>
	</head>
	<body>
		<?php echo "The current time is ".date("Y-m-d H:i:s"); ?> 
	</body>
</html>
<?php HObfus_end(); ?>

You must replace PATH-TO-HObfus.inc.php with the actual path to hobfus/HObfus.inc.php. If you are not sure about the path, see Find the path to HObfus.inc.php for more help.

The position of require_once() is usually at the top of the PHP file, however, you can place it anywhere as long as it comes before the first <?php HObfus_begin(); ?>.

3.  Test your PHP page

Now you are ready to test it. Open the PHP file in your browser and check the source. You should find that the HTML source code is obfuscated.


« Back
Using HObfus
Next »
Obfuscating a Part of a Webpage