PHP encryption technology

Posted by V_dirt_God on Mon, 14 Feb 2022 01:47:01 +0100

Hello, everyone. Meet again. I'm Jun Quan.

PHP encrypted code can run in PHP version above 5 +. Cross platform, Windows, CentOS and Ubuntu platforms can operate normally. Support virtual host, VPS and independent server. No additional extensions need to be installed. Maintain the original code structure and do not inject any additional code. The Web server does not require any modification. Excellent and efficient irreversible encryption obfuscation algorithm. Ultra high encryption strength

1. Be sincere and open. Today I want to tell you how to encrypt the php source code.

In the actual development work, some core or particularly important php pages need to be protected against theft or malicious modification, as well as against those dishonest customers or bosses. At this time, we need to encrypt these files.

2. First of all, we need to build a php running environment locally, or directly put php files in the space where the running environment is php.

Here, I use space.

3. Then create a php file to be encrypted: index (click) php.

$nowTime = time();//Get the timestamp of the current time
$expireTime = 1500103230;//Get the timestamp after two minutes through the timestamp conversion tool
if($nowTime <= $expireTime){
  echo 'The website is running normally!';
  echo 'Website closed!';

Write the encrypted code in it. Here, I use the simplest code as an example. The code idea is as follows: first get the current time, and then use the timestamp conversion tool to get the timestamp after two minutes. Judge whether the current time is less than or equal to the expiration time. If true, return: the website is running normally.

Otherwise, return: the website is closed.

4. Now our protagonist is on the stage, which is encryption (click) php file.

function RandAbc($length=""){//Returns a random string
return str_shuffle($str);
$filename='index.php';//Enter the PHP file that needs to be encrypted
$T_k1=RandAbc();//Random key 1
$T_k2=RandAbc();//Random key 2
$vstr=file_get_contents($filename);//Files to encrypt
$c=strtr($v1,$T_k1,$T_k2);//Replace the corresponding characters according to the key
echo "OK,Encryption complete!";
//Generate encrypted PHP file
$fpp1 = fopen('test.php','w');
fwrite($fpp1,$s) or die('Write file error'); 

You can study the specific implementation steps yourself. Now let me talk about what needs attention.

First, put the full name of the php file to be encrypted in single quotation marks on line 6.

Second, fill in the encrypted php file name in the first single quotation mark in line 26.

5. Now replace the timestamp with the timestamp in two minutes. Then upload these two files to the space.

Execute encryption (click) PHP file.

Then you can see a test in the root directory of the space (click) php file generation.

This test (click) php is created by index (DOT) php encryption.

Then execute test (click) PHP file.

You can see the running results and index (click) the result of running php file is the same. The website will be closed in two minutes.

6. Open test (click) php file, which is the encrypted source code.


Then put the index (click) save the php file, and only run test. php in the space (click) the php file can achieve the encryption effect.

7. Come and test it yourself Publisher: full stack programmer, stack length, please indicate the source for Reprint: Original link: