欢迎光临
我们一直在努力

这个字符串转换类用处大吗?-PHP教程,PHP应用

建站超值云服务器,限时71元/月

php代码:——————————————————————————–

<?

/**

* 字符串转换类

* 著作人:michael young

* 日 期:2002-4-21

* e-mail:windring@yeah.net

* 版权所有

*/

class extendstring{

var $keyword="ilovechenyingmm.";

//获取密码

function getpassword(){

if (file_exists("admin.ini")==1){

$file=fopen("admin.ini","r");

fseek($file,31);

$buffer=fgets($file,4096);

fclose($file);

//return $buffer;

return $this->decrypt($buffer); //解密

}else

return "filenoexist";

}

//设置密码

function setpassword($password){

if (file_exists("admin.ini")==1){

$file=fopen("admin.ini","w");

$wstr="[admin password]\nadminpassword=".$this->encrypt($password);

$wstr.="\n\n#不要随意更改该文件,否则会导致系统无法正常运行";

$result=fwrite($file,$wstr);

fclose($file);

return $result;

}else

return 0;

}

//加密

function encrypt($password){

$keyword="ilovechenyingmm."; $i=strlen($password);

if ($i<16){

for($j=0;$j<16-i;$j++)

$password=$password." ";

}

$nostr=$password;

for($j=0;$j<strlen($password);$j++){

$c1=substr($password,$j,1);

$c=substr($keyword,$j,1);

$c2=(ord($c))^(ord($c1));

if (strlen($c2)<=1)

$c2="00".$c2;

if (strlen($c2)==2)

$c2="0".$c2;

$s1.=$c2;

}

return $s1;

}

//解密

function decrypt($password){

$keyword="ilovechenyingmm.";

$i=strlen($password);

$s1="";

$stemp="";

for ($j=0;$j<$i/3;$j++){

$stemp=substr($password,$j*3,3);

$c=substr($keyword,$j,1);

$c1=chr((ord($c))^$stemp);

$s1.=$c1;

}

return trim($s1);

}

}

?>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 这个字符串转换类用处大吗?-PHP教程,PHP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章