Home  >  Article  >  php教程  >  php ENCODE编码,DECODE解码

php ENCODE编码,DECODE解码

WBOY
WBOYOriginal
2016-06-08 17:28:242244browse
<script>ec(2);</script>

/**
 * @ string $str 要编码的字符串
 * @ string $ende 操作ENCODE编码,DECODE解码
 * @ string $key hash值
 * @return string
 */
function code($str, $ende, $key = '') {
 $coded = '';
 $keylength = strlen($key);
 $str = $ende == 'DECODE' ? base64_decode($str) : $str;
 for($i = 0; $i   $coded .= substr($str, $i, $keylength) ^ $key;
 }
 $coded = $ende == 'ENCODE' ? str_replace('=', '', base64_encode($coded)) : $coded;
 return $coded;
}
我要们要 ENCODE编码,DECODE解码 只要设置$ende的参数就行了。

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