- /**
- * Universal encryption
- * @param String $string The string that needs to be encrypted
- * @param String $skey Encrypted EKY
- * @return String
- */
- function enCode($string = '', $skey = 'echounion') {
- $skey = array_reverse(str_split($skey));
- $strArr = str_split(base64_encode($string));
- $strCount = count($strArr);
- foreach ($skey as $key => $value) {
- $key < $strCount && $strArr[$key].=$value;
- }
- return str_replace('=', 'O0O0O', join('', $strArr));
- }
- /**
- * Universal decryption
- * @param String $string The string to be decrypted
- * @param String $skey Decryption KEY
- * @return String
- */
- function deCode($string = '', $skey = 'echounion') {
- $skey = array_reverse(str_split($skey));
- $strArr = str_split(str_replace('O0O0O', '=', $string), 2);
- $strCount = count($strArr);
- foreach ($skey as $key => $value) {
- $key < $strCount && $strArr[$key] = rtrim($strArr[$key], $value);
- }
- return base64_decode(join('', $strArr));
- }
复制代码
|