html5中文学习网

您的位置: 首页 > 网络编程 > PHP编程 » 正文

encryptlib PHP的一个加密库_PHP教程_编程技术

[ ] 已经帮助:人解决问题
加密

<?php

 function kPHPCrypt($strDataIn) {
  return StrRevCrypt(ROT13Crypt($strDataIn));
 }

 function ROT13Crypt($strDataIn) {
 
  //ABCDEFGHIJKLM
  //NOPQRSTUVWXYZ

  $newString = "";
 
  for ($i = 0; $i < strlen($strDataIn); $i++) {

   $temp = substr($strDataIn, $i, 1);
   $asc = ord($temp);

   $newChar = $temp;

   if (($asc >= 65) && ($asc <= 90)) {
    if ($asc <= 65 + 12) $newChar = chr($asc + 13);
    if ($asc >= 65 + 13) $newChar = chr($asc - 13);
   }
  
   if (($asc >= 97) && ($asc <= 122)) {
    if ($asc <= 97 + 12) $newChar = chr($asc + 13);
    if ($asc >= 97 + 13) $newChar = chr($asc - 13);
   }

   $newString = $newString . $newChar;  
  
  }

  return $newString;

 }


 function StrRevCrypt($strDataIn) {

  $newString = "";
 
  for ($i = strlen($strDataIn) - 1; $i >= 0; $i--) {
   $temp = substr($strDataIn, $i, 1);
   $newString = $newString . $temp;
  }

  return $newString;

 }

?>

 

idzHTML5中文学习网 - HTML5先行者学习网
idzHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助