宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > PHP教程

[PHP]来做php源代码加密与加密

2016-10-13 00:16:48 点击量:10 标签: 收藏本文

本篇文章小编为大家介绍,怎样给PHP源代码加密?PHP二进制加密与解密的解决办法。需要的朋友参考下:

加密方式1:

  1. <?php  
  2.  function encode_file_contents($filename) {  
  3.      $type=strtolower(substr(strrchr($filename,'.'),1));  
  4.      if ('php' == $type && is_file($filename) && is_writable($filename)) { // 如果是PHP文件 并且可写 则进行压缩编码  
  5.          $contents = file_get_contents($filename); // 判断文件是否已经被编码处理  
  6.          $contents = php_strip_whitespace($filename);   
  7.  
  8.          // cuplayre.com去除PHP头部和尾部标识  
  9.          $headerPos = strpos($contents,'<?php');  
  10.          $footerPos = strrpos($contents,'?>');  
  11.          $contents = substr($contents, $headerPos + 5, $footerPos - $headerPos);  
  12.          $encode = base64_encode(gzdeflate($contents)); // 开始编码  
  13.          $encode = '<?php'."\n eval(gzinflate(base64_decode("."'".$encode."'".")));\n\n?>";   
  14.  
  15.          return file_put_contents($filename, $encode);  
  16.      }  
  17.      return false;  
  18.  }   
  19.  
  20.  //cuplayer.com调用函数  
  21.  $filename = 'dam.php';  
  22.  encode_file_contents($filename);  
  23.  echo "OK,cuplayer.com加密完成!" 
  24.  ?>  

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室