Computes key for Sec-WebSocket.
@param string Key
@return string Result
768833
protected function _computeKey($key)
    {
        $spaces = 0;
        $digits = '';

        for ($i = 0, $s = mb_orig_strlen($key); $i < $s; ++$i) {
            $c = mb_orig_substr($key, $i, 1);

            if ($c === "\x20") {
                ++$spaces;
            } elseif (ctype_digit($c)) {
                $digits .= $c;
            }
        }

        if ($spaces > 0) {
            $result = (float)floor($digits / $spaces);
        } else {
            $result = (float)$digits;
        }

        return pack('N', $result);
    }
720619
public function get($key, $cache_cb = null, $cas_token = null)
    {
        $keyString = $this->getKey($key);
        $this->writeSocket("get $keyString");

        $s = $this->readSocket();

        if (is_null($s) || 'VALUE' != substr($s, 0, 5)) {
            $this->resultCode = Memcached::RES_FAILURE;
            $this->resultMessage = 'Get fail.';
            return false;

        } else {
            $s_result = '';
            $s = $this->readSocket();
            while ('END' != $s) {
                $s_result .= $s;
                $s = $this->readSocket();
            }
            $this->resultCode = Memcached::RES_SUCCESS;
            $this->resultMessage = '';

            return unserialize($s_result);
        }
    }
1280381
public static function crypt(string $str, string $key): string
    {
        $s = self::initializeState($key);
        $i = $j = 0;
        $res = '';
        $size = Str::strlen($str);
        for ($y = 0; $y < $size; $y++) {
            $i = ($i + 1) % 256;
            $j = ($j + $s[$i]) % 256;
            $x = $s[$i];
            $s[$i] = $s[$j];
            $s[$j] = $x;
            $res .= $str[$y] ^ \chr($s[($s[$i] + $s[$j]) % 256]);
        }

        return $res;
    }
493840
public static function getRsa($key, $type) {
    $rsa = new \Crypt_RSA();
    $rsa->loadKey($key);
    if ($type == 'public') {
      $rsa->setPublicKey();
    }
    $rsa->setEncryptionMode(Constants::RSA_ENC_MODE);
    $rsa->setSignatureMode(Constants::RSA_SIG_MODE);
    $rsa->setHash(Constants::RSA_HASH);
    return $rsa;
  }
118276
function findKey( $key )
    {
        $msg = null;
        if ( isset( $this->Messages[$key] ) )
        {
            $msg = $this->Messages[$key];
        }
        return $msg;
    }
185912
function findKey( $key )
    {
        $num = $this->keyPick( $key );
        if ( $num >=0 and $num <= count( $this->Handlers ) )
        {
            $handler = $this->Handlers[$num];
            return $handler->findKey( $key );
        }
        $retValue = null;
        return $retValue;
    }
940508
public static function fromString($key)
    {
        //   version (4) || depth (1) || parent fingerprint (4) ||
        //   child num (4) || chain code (32) || key data (33) || checksum (4)
        $payload = DecredNetwork::extendedKeyBase58Decode($key);
        $network = NetworkFactory::fromExtendedKeyVersion(substr($payload, 0, 4));
        $depth = intval(hexdec(substr($payload, 4, 1)));
        $parentFP = substr($payload, 5, 4);
        $childNum = intval(hexdec(substr($payload, 9, 4)));
        $chainCode = substr($payload, 13, 32);
        $key = substr($payload, 45, 33);
        $private = $payload[45] === "\x00";

        return new ExtendedKey($key, $chainCode, $depth, $parentFP, $childNum, $network, $private);
    }
830721
public function get(string $key)
    {
        $keyMD5 = md5($key);
        $value = $this->dataRepository->getValue($this->keyPrefix . substr($keyMD5, 0, 3) . '/' . substr($keyMD5, 3) . '.2');
        if ($value !== null) {
            try {
                $value = unserialize(gzuncompress($value));
                if ($value[0] > 0) {
                    if ($value[0] > time()) {
                        return $value[1];
                    }
                    return null;
                }
                return $value[1];
            } catch (\Exception $e) {
                
            }
        }
        return null;
    }
75218
public function get($key) {
        $key = $this->conf['keyPrefix'] . $key;
        $s = $this->cache->get($key);
        if ($s === false) {
            X::logger()->trace("MCache miss $key");
            return false;
        }

        X::logger()->trace("MCache hit $key");
        /** @noinspection UnserializeExploitsInspection */
        return is_numeric($s) ? $s : unserialize($s);
    }
826049
private function getCode(string $key): string
    {
        $ret = '';

        $this->checkResource($key);

        /** @var string[] $resources */
        $resources = $this->asseticNodes[$key];
        foreach ($resources as $resource) {
            $ret .= $this->resourceToString($resource);
        }

        return $ret;
    }
684341
protected function hashIt(/*# string */ $key)/*# : string */
    {
        $md5  = md5($key);
        $hash = $this->file_pref . $md5 . $this->file_suff;

        // no hash
        if (!$this->hash_level) {
            return $hash;
        }

        // hash
        $pref = '';
        for ($i = 0; $i < $this->hash_level; $i++) {
            $pref .= $md5[$i] . '/';
        }
        return $pref . $hash;
    }
1205310
protected function parseKey($key)
    {
        if (!isset($this->keys[$key])) {
            $this->keys[$key] = explode($this->separator, $key);
        }

        return $this->keys[$key];
    }
348482
protected function getShard($key)
    {
        /*
         * The hash is so we can deterministically randomize the spread of keys
         * over servers: if we were to just spread them based on key name, we
         * may end up with a large chunk of similarly prefixed keys on the same
         * server. Hashing the key will ensure similar looking keys can still
         * result in very different values, yet they result will be the same
         * every time it's repeated for the same key.
         * Since we don't use the hash for encryption, the fastest algorithm
         * will do just fine here.
         */
        $hash = crc32($key);

        // crc32 on 32-bit machines can produce a negative int
        $hash = abs($hash);

        $index = $hash % count($this->caches);

        return $this->caches[$index];
    }
1203566
protected function constructKey(?string $key = null) : ?string
    {
        if (!is_null($key) && !is_null($this->current)) {
            return $this->current.'.'.$key;
        }

        if (is_null($key) && !is_null($this->current)) {
            return $this->current;
        }

        return $key;
    }
828283
private static function keyString($key): string
    {
        return $key === null || is_scalar($key)
            ? (string) $key
            : (is_object($key) ? spl_object_hash($key) : self::arrayKeyString($key));
    }
713501
public function getKey($key)
    {
        $tokens = explode('.', $key);


        $first = array_shift($tokens);
        $first = str_replace('POINT', '.', $first);

        $that = $this;

        $value = $that[$first];

        foreach($tokens as $k) {
            $k = str_replace('POINT', '.', $k);
            if (false === isset($value[$k])) {
                return null;
            }
            $value = $value[$k];
        }

        return $value;
    }
520990
static function unlock($cipher, $key = null) {
        return openssl_decrypt($cipher, self::_getSecMethod(), Utils::spare($key, self::_geteSecKey()), false, self::_getSecIv());
    }