怎么在php项目中自定义一个加密与解密程序

介绍

这期内容当中小编将会给大家带来有关怎么在php项目中自定义一个加密与解密程序,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

php有什么用

php是一个嵌套的缩写名称,是英文超级文本预处理语言,它的语法混合了C、Java、Perl以及php自创新的语法,主要用来做网站开发,许多小型网站都用php开发,因为php是开源的,从而使php经得久不衰。

代码如下:

$ ralphabet=癆BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 !。, ? ~ @ # $ % ^, *() _ + -=][}{/祝辞;& lt;“& # 39;,,,
字母表=ralphabet美元。ralphabet美元;
,
类加密{
,
函数加密(密码,strtoencrypt美元){
,
全球ralphabet;美元,
全球美元字母;
,
($ i=0;美元i {,
$ cur_pswd_ltr=substr(密码,我美元,1),,
pos_alpha_ary美元[]=substr (strstr(字母,cur_pswd_ltr美元),0,strlen (ralphabet美元)),,
}
,
=0;美元,
$ n=0,,
nn=strlen(密码)美元;美元,
$ c=strlen ($ strtoencrypt);
,
(i {,
encrypted_string美元。=substr (pos_alpha_ary美元($ n),大小写敏感(ralphabet美元,substr (strtoencrypt美元,美元我,1)),1);
,
$ n + +,,
如果nn)美元($ n==n=0,,
我+ +,美元,
}
,
返回encrypted_string美元;
,
}
,
功能解密(密码,strtodecrypt美元){
,
全球ralphabet;美元,
全球美元字母;
,
($ i=0;美元i {,
$ cur_pswd_ltr=substr(密码,我美元,1),,
pos_alpha_ary美元[]=substr (strstr(字母,cur_pswd_ltr美元),0,strlen (ralphabet美元)),,
}
,
=0;美元,
$ n=0,,
nn=strlen(密码)美元;美元,
$ c=strlen ($ strtodecrypt);
,
(i {,
decrypted_string美元。=substr (ralphabet美元,大小写敏感(pos_alpha_ary美元($ n), substr (strtodecrypt美元,美元我,1)),1);
,
$ n + +,,
如果nn)美元($ n==n=0,,
我+ +,美元,
}
,
返回decrypted_string美元;
,
}
,
函数cryption_table(密码){
,
全球ralphabet;美元,
全球美元字母;
,
($ i=0;美元i {,
$ cur_pswd_ltr=substr(密码,我美元,1),,
pos_alpha_ary美元[]=substr (strstr(字母,cur_pswd_ltr美元),0,strlen (ralphabet美元)),,
}
,
打印“& lt;表边界=1单元格边距=?”;单元格间距=?“祝辞n";
,
打印“& lt; tr> & lt; td> & lt;/td>“,
($ j=0;美元j {,
打印“& lt; td对齐=癱enter"祝辞& lt;字体大??”;“面对=癮rial";。substr (ralphabet, j,美元1)。“& lt;/td> n",,
},
打印“& lt;/tr>“;
,
,
($ i=0;i<美元;count ($ pos_alpha_ary);美元我+ +),
{,
打印“& lt; tr> & lt; td对齐=皉ight"祝辞& lt;字体大??“祝辞& lt; b>“。(i + 1美元)。“| & lt;/b> & lt;/font> & lt;/td>“,
($ k=0;k<美元;strlen ($ pos_alpha_ary [$ i]);$ k + +),
{,
打印“& lt; td对齐=癱enter"祝辞& lt;字体大??”;“面对=癮rial";。substr (pos_alpha_ary美元($ i), $ k, 1)。“& lt;/td> n",,
},
打印“& lt;/tr>“,
}
,
打印“& lt;/table> n";
,
}
,
}//结束类加密
,
//宏Zeng 写的例子;
$ ct=新密码,,
//ct→美元cryption_table(密码),,
回声“& lt;表单动作=$ PHP_SELF方法=post>,,,
if ($ mod==2) {,
strtodecrypt=美元ct→加密(密码,strtoencrypt美元),,
回声& # 39;加密字符串(加密后的字段):& # 39;,,
回声“& lt;输入类型=文本名称=strtodecrypt大?45值=https://www.yisu.com/zixun/$ strtodecrypt>”;
回声“密码锁:& lt;输入类型=name=密码文本大?6价值=https://www.yisu.com/zixun/$密码>”;
回声“& lt;输入类型=value=https://www.yisu.com/zixun/提交“解密(解密)“>”;
},{
其他,
strtoencrypt=ct→美元解密(密码,strtodecrypt美元),,
回声& # 39;字符串加密(需要加密的字段):& # 39;,,
回声“& lt;输入类型=文本名称=strtoencrypt大?45值=https://www.yisu.com/zixun/$ strtoencrypt>”;
回声“密码锁:& lt;输入类型=name=密码文本大?6价值=https://www.yisu.com/zixun/$密码>”;
回声“& lt;输入类型=value=https://www.yisu.com/zixun/提交“加密(加密)“>”;
回声“& lt;输入类型=隐藏名字=国防部价值=https://www.yisu.com/zixun/2>”;
},
回声“& lt;/form>“

代码如下:


中将(“crypto.php");null

怎么在php项目中自定义一个加密与解密程序