mhx
说明：symmetry 简单对称加密算法之解密
@param string $string 需要解密的字串
@param string $skey $skey 解密KEY
@param array $mix
@return string
185172
public static function sDecode($string = '', $skey = 'wenzi' , $mix = array('#b1'=>'+' , '#b2'=>'/' , '@A' => ' ')) {
        $string = base64_decode( $string , TRUE  );
        if($mix){
            $arrayKey = array_keys($mix);
            $arrayValue = array_values($mix);
            $string = str_replace($arrayKey,$arrayValue , $string);
        }
        $strlen = strlen($string);
        $skLen = strlen($skey);
        $str = '';
        for($i=0; $i < $strlen ; $i++){
            $sI =  $i % $skLen;
            $str .= $string[$i] ^ $skey[$sI];
        }

        return base64_decode($str , true);
    }
472817
protected function setCache($sKey, $mValue)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        // --------------------------------------------------------------------------

        //  Test we're not near memory limit
        if (function_exists('ini_get')) {
            $sMemoryLimit = ini_get('memory_limit_cat');
            if ($sMemoryLimit !== false) {
                $sLastChar = strtoupper($sMemoryLimit[strlen($sMemoryLimit) - 1]);
                switch ($sLastChar) {
                    // The 'G' modifier is available since PHP 5.1.0
                    case 'G':
                        $sMemoryLimit *= 1024;
                    /* falls through */
                    case 'M':
                        $sMemoryLimit *= 1024;
                    /* falls through */
                    case 'K':
                        $sMemoryLimit *= 1024;
                }

                $fPercentage = (memory_get_usage() / $sMemoryLimit) * 100;
                if ($fPercentage > 90) {
                    $this->clearCache();
                }
            }
        }

        // --------------------------------------------------------------------------

        //  Prep the key, the key should have a prefix unique to this model
        $iCacheIndex = $this->getCache($sKey, false);
        if (!is_null($iCacheIndex)) {
            $this->aCache[$iCacheIndex]->value = $mValue;
        } else {
            $sCacheKey      = $this->getCachePrefix() . $sKey;
            $this->aCache[] = (object) [
                'key'   => [$sCacheKey],
                'value' => $mValue,
            ];
        }

        // --------------------------------------------------------------------------

        return true;
    }
1278632
public function get($sKey = null, $sGrouping = 'app', $bForceRefresh = false)
    {
        if (!isset($this->aSettings[$sGrouping]) || $bForceRefresh) {

            $oDb = Factory::service('Database');
            $oDb->where('grouping', $sGrouping);
            $aSettings = $oDb->get($this->sTable)->result();

            $this->aSettings[$sGrouping] = [];

            foreach ($aSettings as $oSetting) {

                $sValue = $oSetting->value;

                if (!empty($oSetting->is_encrypted)) {
                    $oEncrypt = Factory::service('Encrypt');
                    $sValue   = $oEncrypt->decode($sValue);
                }

                $this->aSettings[$sGrouping][$oSetting->key] = json_decode($sValue);
            }
        }

        // --------------------------------------------------------------------------

        if (empty($sKey)) {

            return $this->aSettings[$sGrouping];

        } else {

            return isset($this->aSettings[$sGrouping][$sKey]) ? $this->aSettings[$sGrouping][$sKey] : null;
        }
    }
925089
protected function getSettingValue($sKey)
    {
        $arSettings = $this->settings;
        if (empty($sKey) || empty($arSettings) || !isset($arSettings[$sKey])) {
            return null;
        }

        return $arSettings[$sKey];
    }
822628
function mixkey(seed, key, smear, j) {
  seed += '';                         // Ensure the seed is a string
  smear = 0;
  for (j = 0; j < seed.length; j++) {
    key[lowbits(j)] =
      lowbits((smear ^= key[lowbits(j)] * 19) + seed.charCodeAt(j));
  }
  seed = '';
  for (j in key) { seed += String.fromCharCode(key[j]); }
  return seed;
}
941930
private function _str2hex($string)
    {
        $hex = bin2hex($string);
        $xhex = "";

        for ($i = 0; $i < strlen($hex) - 1; $i += 2) {
            $xhex .= '\x' . $hex[$i] . $hex[$i + 1];
        }

        return $xhex;
    }
710783
public void key( String skey ) throws jsqlite.Exception {
        synchronized (this) {
            byte ekey[] = null;
            if (skey != null && skey.length() > 0) {
                ekey = new byte[skey.length()];
                for( int i = 0; i < skey.length(); i++ ) {
                    char c = skey.charAt(i);
                    ekey[i] = (byte) ((c & 0xff) ^ (c >> 8));
                }
            }
            _key(ekey);
        }
    }
206321
public function parsePkWhere($data)
    {
        $pk = $this->getPk();

        if (is_string($pk)) {
            // 根据主键查询
            if (is_array($data)) {
                $where[$pk] = isset($data[$pk]) ? [$pk, '=', $data[$pk]] : [$pk, 'in', $data];
            } else {
                $where[$pk] = strpos($data, ',') ? [$pk, 'IN', $data] : [$pk, '=', $data];
            }
        }

        if (!empty($where)) {
            if (isset($this->options['where']['$and'])) {
                $this->options['where']['$and'] = array_merge($this->options['where']['$and'], $where);
            } else {
                $this->options['where']['$and'] = $where;
            }
        }

        return;
    }
1011824
public static function textEncode( $mix )
    {
        if ( is_array( $mix ) )
            return implode(',', array_map( array('ezjscAjaxContent', 'textEncode'), array_filter( $mix ) ) );

        return htmlspecialchars( $mix );
    }
396329
public static function binEnc($string, $pass, $key_size = null)
    {
        return self::enc($string, $pass, $key_size, true);
    }
1164699
protected static function _checkKey($sKey) {
		if ($sKey === '_id') {
			return FALSE;
		}
		if ($sKey === static::$_mKey) {
			return FALSE;
		}
		if (strpos($sKey, '.') !== FALSE) {
			return FALSE;
		}
		if (substr($sKey, 0, 1) === '$') {
			return FALSE;
		}
		return TRUE;
	}
1224332
public function fromPhpFileCache($sKey)
    {
        // setting meta
        $this->setCacheMeta($sKey, ["include" => true, "cachepath" => $this->getCacheFilePath($sKey, false, 'php')]);

        return $this->fromFileCache($sKey);
    }
255404
private function getIntStringFromValue($mix_val)
    {
        $int = null;
        $str = null;
        if($mix_val instanceof Value) {
            if($mix_val->hasIntegerValue()) {
                $int = $mix_val->getIntegerValue();
            } else {
                $str = $mix_val->getStringValue();
            }
        } else {
            if(is_numeric($mix_val)) {
                $int = $mix_val;
            } else {
                $str = $mix_val;
            }
        }
        return [$int, $str];
    }
772889
protected function unsetCache($sKey)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        $iCacheIndex = $this->getCache($sKey, false);
        if (is_null($iCacheIndex)) {
            return false;
        }

        unset($this->aCache[$iCacheIndex]);

        return true;
    }
567387
public static function inArrayMulti($sValue, $sKey, array $aArray): bool
    {
        return static::arraySearchMulti($sValue, $sKey, $aArray) !== false;
    }
1363368
public static String mix(String code, int key) throws IOException {
        return xor(JavaDecrypt.base64(ascii(code, key)), key);
    }
1060228
public function sAdd($skey, $value) {
        return $this->_connection->sadd($this->getUsedKey($skey), $value);
    }