Home >Backend Development >PHP Tutorial >一PHP可逆加解密算法

一PHP可逆加解密算法

WBOY
WBOYOriginal
2016-06-20 12:39:15791browse

求助一PHP可逆加解密算法
例如算法规则:
a=b
b=c
c=d
d=e
……
x=y
y=z
z=a
0=1
1=2
2=3
……
8=9
9=0
字母与数字都按一定的大小字母或数字替换
例子:
加密前内容:123abc
加密成:234def
就这样子,同时能按替换的规则来解密还原
请大家帮我这个效果,谢谢


回复讨论(解决方案)

$dict = array(  'a' => 'b',  'b' => 'c',  'c' => 'd',  'd' => 'e',  '0' => '1',  '1' => '2',  '2' => '3',  '3' => '4',);echo $t = strtr('123abc',$dict), PHP_EOL;echo strtr($t, array_flip($dict));
234bcd123abc

非常感谢,原来是这两个函数

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP中的FPM是做什么的Next article:构建安全的PHP应用