src/Core/Helper.php
static function encodeParams($str, $key, $operation = 'encode')
    {
        $result = '';
        static $key_cache;
        if (!isset($key_cache[$key])) {
            $key_cache[$key] = md5($key);
        }

        $key = $key_cache[$key];
        if ($operation == 'encode') {
            $str = (string)$str;
        } else {
            //校验数据完整性
            //省略校验要解密的参数是否是一个16进制的字符串
            $str_head = substr($str, 0, 5);
            $str = substr($str, 5);
            if ($str_head != substr(md5($str . $key), 9, 5)) {
                return $result;
            }

            $str = pack('H*', $str);
        }

        if (!$str) {
            return $result;
        }

        for ($str_len = strlen($str), $i = 0; $i < $str_len; $i++) {
            $result .= chr(ord($str[$i]) ^ ord($key[$i % 32]));
        }

        if ($operation == 'encode') {
            $result = bin2hex($result);
            $result = substr(md5($result . $key), 9, 5) . $result;
        }

        return $result;
    }
static function encodeParams($str, $key, $operation = 'encode')
    {
        $result = '';
        static $key_cache;
        if (!isset($key_cache[$key])) {
            $key_cache[$key] = md5($key);
        }

        $key = $key_cache[$key];
        if ($operation == 'encode') {
            $str = (string)$str;
        } else {
            //校验数据完整性
            //省略校验要解密的参数是否是一个16进制的字符串
            $str_head = substr($str, 0, 5);
            $str = substr($str, 5);
            if ($str_head != substr(md5($str . $key), 9, 5)) {
                return $result;
            }

            $str = pack('H*', $str);
        }

        if (!$str) {
            return $result;
        }

        for ($str_len = strlen($str), $i = 0; $i < $str_len; $i++) {
            $result .= chr(ord($str[$i]) ^ ord($key[$i % 32]));
        }

        if ($operation == 'encode') {
            $result = bin2hex($result);
            $result = substr(md5($result . $key), 9, 5) . $result;
        }

        return $result;
    }
简单字符串加解密

@param string $str
@param string $key
@param string $operation encode加密 其他任意字符解密
@return string