Home > php教程 > PHP源码 > body text

php ENCODE编码,DECODE解码

WBOY
Release: 2016-06-08 17:28:24
Original
2259 people have browsed it
<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的参数就行了。

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template