Decrypt the string encryption
with mCrypt, make sure lib mCrypt is active by your php

@param  mixed $string the value of cookies value
@param  mixed $hash

@return mixed real cookie value
510918
public static function decrypt($string, $hash = false)
    {
        // if has $string or invalid no value or not as string stop here
        if (!is_string($string) || strlen(trim($string)) < 4
            || (strlen($string) > 10 ? (substr($string, 10, 5) !== '_mCb=') : (substr($string, 2, 5) !== '_mCb='))
        ) {

            // check if mCrypt is not loaded and decrypt using alt decrypt
            if (is_string($string)
                && strlen(trim($string)) > 3
                && (strlen($string) > 10 ? (substr($string, 10, 5) === '_aCb=') : (substr($string, 2, 5) === '_aCb='))
            ) {
                return static::altDecrypt($string, $hash);
            }

            return null;
        }

        if (! extension_loaded('mCrypt')) {
            return null;
        }

        /**
         * Replace Injection 3 characters sign
         */
        $string = (strlen($string) > 10
            ? substr_replace($string, '', 10, 5)
            : substr_replace($string, '', 2, 5)
        );
        // this is base64 safe encoded?
        if (preg_match('/[^a-z0-9\+\/\=\-\_]/i', $string)) {
            return null;
        }

        /**
         * ------------------------------------
         * Safe Sanitized hash
         * ------------------------------------
         */
        (is_null($hash) || $hash === false) && $hash = '';
        // safe is use array or object as hash
        $hash        = Util::maybeSerialize($hash);

        /**
         * ------------------------------------
         * Set Key
         * ------------------------------------
         */
        $key         = pack('H*', sha1(sha256::hash($hash)));
        /**
         * pad to 24 length
         * on PHP 5.5 + need keylength 16, 24 or 32
         */
        $key         = str_pad($key, 24, "\0", STR_PAD_RIGHT);

        /**
         * Doing decode of input encryption
         */
        $crypted_text   = Util::safeBase64Decode($string);
        
        /**
         * ------------------------------------
         * Doing deryption
         * ------------------------------------
         */
        $iv_size     = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv          = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $decrypted_text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $crypted_text, MCRYPT_MODE_ECB, $iv);

        /**
         * unserialize the string, that before has been serialize
         */
        $decrypted_text = Util::maybeUnSerialize(trim($decrypted_text));

        /**
         * Check if value is array
         */
        if (is_array($decrypted_text) && array_key_exists('mcb', $decrypted_text)) {
            unset($string, $key, $iv);
            return $decrypted_text['mcb'];
        }

        // freed the memory
        unset($decrypted_text, $crypted_text, $string, $key, $iv);

        return null;
    }
897367
public static function hash($string)
    {
        $salt = self::createSalt();
        return self::PREFIX.$salt.'$'.self::createSubHash($string, $salt);
    }
38637
function decrypt($enc_string,$base64_decode=true){
		if(is_null($enc_string) || empty($enc_string)) return NULL;
		if(!$this->verified) $this->verify();
		//decrypt and return
		if($base64_decode) $enc_string = base64_decode($enc_string);
		$plain_string = mcrypt_decrypt(
			 self::$crypt_cipher
			,base64_decode($this->key)
			,$enc_string
			,self::$crypt_mode
			,base64_decode($this->iv)
		);
		//get size of string from atom
		$size = unpack('N',substr($plain_string,0,4));
		$size = array_shift($size);
		//make sure we have the original string
		$plain_string = substr($plain_string,4,$size);
		return $plain_string;
	}
912250
public function decrypt($string)
  {
    $string = base64_decode($string);
    $decryp = "";
    $length = strlen($string);
    $string .= str_repeat(chr(0), (8-($length%8))%8);

    for($i = 0; $i < $length; $i += 8)
    {
      list(,$xl,$xr) = unpack("N2", substr($string, $i, 8));
      $this->decipher($xl, $xr);
      $decryp .= pack("N2", $xl, $xr);
    }

    return trim($decryp);
  }
272289
public static function getPassword(string $string) :string {
		// get a signature using (the provided string + salt)
		return(hash(Config::get('security','algo'),
			Config::get('security','salt') . $string . Config::get('security','salt')
		));
	}
926482
public function generateKey($string)
    {
        $limit = $this->getConfig()->key_length;
        $key   = strtolower($string);

        if(!isset($this->_keys[$string]))
        {
            if (!$limit || strlen($key) <= $limit)
            {
                $key = strip_tags($key);
                $key = preg_replace('#\s+#m', ' ', $key);
                $key = preg_replace('#\{([A-Za-z0-9_\-\.]+)\}#', '$1', $key);
                $key = preg_replace('#(%[^%|^\s|^\b]+)#', 'X', $key);
                $key = preg_replace('#&.*?;#', '', $key);
                $key = preg_replace('#[\s-]+#', '_', $key);
                $key = preg_replace('#[^A-Za-z0-9_]#', '', $key);
                $key = preg_replace('#_+#', '_', $key);
                $key = trim($key, '_');
                $key = trim(strtoupper($key));
            }
            else
            {
                $hash = substr(md5($key), 0, 5);
                $key  = $this->generateKey(substr($string, 0, $limit));
                $key .= '_'.strtoupper($hash);
            }
        }
        else $key = $this->_keys[$string];

        return $key;
    }
1074200
protected function encrypt($string)
    {
        $iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);

        return mcrypt_encrypt($this->cipher, $this->secretKey, $string, $this->cipherMode, $iv);
    }
42952
public static function decode($hash)
    {
        $minlng = -180;
        $maxlng = 180;
        $minlat = -90;
        $maxlat = 90;

        for ($i=0,$c=strlen($hash); $i<$c; $i++) {
            $v = strpos(self::$table, $hash[$i]);
            if (1&$i) {
                if (16&$v) {
                    $minlat = ($minlat + $maxlat) / 2;
                } else {
                    $maxlat = ($minlat + $maxlat) / 2;
                }
                if (8&$v) {
                    $minlng = ($minlng + $maxlng) / 2;
                } else {
                    $maxlng = ($minlng + $maxlng) / 2;
                }
                if (4&$v) {
                    $minlat = ($minlat + $maxlat) / 2;
                } else {
                    $maxlat = ($minlat + $maxlat) / 2;
                }
                if (2&$v) {
                    $minlng = ($minlng + $maxlng) / 2;
                } else {
                    $maxlng = ($minlng + $maxlng) / 2;
                }
                if (1&$v) {
                    $minlat = ($minlat + $maxlat) / 2;
                } else {
                    $maxlat = ($minlat + $maxlat) / 2;
                }
            } else {
                if (16&$v) {
                    $minlng = ($minlng + $maxlng) / 2;
                } else {
                    $maxlng = ($minlng + $maxlng) / 2;
                }
                if (8&$v) {
                    $minlat = ($minlat + $maxlat) / 2;
                } else {
                    $maxlat = ($minlat + $maxlat) / 2;
                }
                if (4&$v) {
                    $minlng = ($minlng + $maxlng) / 2;
                } else {
                    $maxlng = ($minlng + $maxlng) / 2;
                }
                if (2&$v) {
                    $minlat = ($minlat + $maxlat) / 2;
                } else {
                    $maxlat = ($minlat + $maxlat) / 2;
                }
                if (1&$v) {
                    $minlng = ($minlng + $maxlng) / 2;
                } else {
                    $maxlng = ($minlng + $maxlng) / 2;
                }
            }
        }

        return array($minlng, $maxlng, $minlat, $maxlat);
    }
18130
public static function fromHeader(string $string): Cookie
    {
        $parts = array_filter(array_map('trim', explode(';', $string)));

        if (empty($parts) || !strpos($parts[0], '=')) {
            throw new InvalidValueException('Invalid cookie format.');
        }

        list($name, $value) = array_map('trim', explode('=', array_shift($parts), 2));

        $expires = 0;
        $path = '';
        $domain = '';
        $secure = false;
        $httpOnly = false;

        foreach ($parts as $part) {
            $pieces = array_map('trim', explode('=', $part, 2));
            $key = strtolower($pieces[0]);

            if (1 === count($pieces)) {
                switch ($key) {
                    case 'secure':
                        $secure = true;
                        break;

                    case 'httponly':
                        $httpOnly = true;
                        break;
                }
            } else {
                switch ($key) {
                    case 'expires':
                        $time = \DateTime::createFromFormat('D, j M Y G:i:s T', $pieces[1]);
                        if (false === $time) {
                            break;
                        }

                        $time = $time->getTimestamp();
                        $expires = 0 === $expires ? $time : min($time, $expires);
                        break;

                    case 'max-age':
                        $time = trim($pieces[1]);
                        if (ctype_digit($time)) {
                            break;
                        }

                        $time = time() + (int) $time;
                        $expires = 0 === $expires ? $time : min($time, $expires);
                        break;

                    case 'path':
                        $path = $pieces[1];
                        break;

                    case 'domain':
                        $domain = $pieces[1];
                        break;
                }
            }
        }

        return new self($name, $value, $expires, $path, $domain, $secure, $httpOnly);
    }
871491
protected function decrypt($string, $key){
        return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
    }
1170092
function hash($text)
    {
        $mode = is_array($this->hash) ? self::MODE_INTERNAL : CRYPT_HASH_MODE;

        if (!empty($this->key) || is_string($this->key)) {
            switch ($mode) {
                case self::MODE_MHASH:
                    $output = mhash($this->hash, $text, $this->key);
                    break;
                case self::MODE_HASH:
                    $output = hash_hmac($this->hash, $text, $this->key, true);
                    break;
                case self::MODE_INTERNAL:
                    /* "Applications that use keys longer than B bytes will first hash the key using H and then use the
                        resultant L byte string as the actual key to HMAC."

                        -- http://tools.ietf.org/html/rfc2104#section-2 */
                    $key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key;

                    $key    = str_pad($key, $this->b, chr(0));      // step 1
                    $temp   = $this->ipad ^ $key;                   // step 2
                    $temp  .= $text;                                // step 3
                    $temp   = call_user_func($this->hash, $temp);   // step 4
                    $output = $this->opad ^ $key;                   // step 5
                    $output.= $temp;                                // step 6
                    $output = call_user_func($this->hash, $output); // step 7
            }
        } else {
            switch ($mode) {
                case self::MODE_MHASH:
                    $output = mhash($this->hash, $text);
                    break;
                case self::MODE_HASH:
                    $output = hash($this->hash, $text, true);
                    break;
                case self::MODE_INTERNAL:
                    $output = call_user_func($this->hash, $text);
            }
        }

        return substr($output, 0, $this->l);
    }
675410
protected function _convert($string) {
		$symbols = $this->_symbols;

		$result = array_map(function($value) use ($symbols) {
			return $symbols[ord($value) & (count($symbols) - 1)];
		}, str_split(hash('sha1', $string)));

		return implode('', $result);
	}
347426
public function checkhash($string, $hashedString)
	{
		$verified = password_verify($string, $hashedString);
		if ( ! $verified) 
		{
			// Try the fallbacks
			foreach (static::$fallbacks as $algo => $fallback)
			{
				$verified = $fallback['function']($string, $hashedString, $fallback['options']);
				if ($verified) break;
			}
		}
		return $verified;
	}
1278983
public function decodeReversibleString($string)
    {

        $salt = $this->getSecretAppString();

        $key = substr(base64_encode($salt), 0, 50);
        $iv = '12345678';
        $cc = base64_decode($string);

        $cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');

        mcrypt_generic_init($cipher, $key, $iv);
        $decrypted = mdecrypt_generic($cipher, $cc);
        mcrypt_generic_deinit($cipher);

        return json_decode(base64_decode($decrypted), true)['key'];
    }
236679
public function decrypt($string, $key = null)
    {
        if (null === $key) {
            $key = $this->getEncryptKey();
        }

        $cipherText = base64_decode($string);
        $ivSize     = $this->getMsCryptIvSize();

        $ivDec = substr($cipherText, 0, $ivSize);

        $cipherText = substr($cipherText, $ivSize);

        return mcrypt_decrypt(
            $this->getMcryptCipher(),
            $key,
            $cipherText,
            $this->getMcryptMode(),
            $ivDec
        );
    }
347951
public function encodeReversibleString($string)
    {

        $salt = $this->getSecretAppString();

        $key = substr(base64_encode($salt), 0, 50);
        $iv = '12345678';
        $cc = base64_encode(json_encode(array(
            'time' => strrev('' . time()),
            'key' => $string,
            'random' => rand(10000000, 99999999)
        )));

        $cipher = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'cbc', '');

        mcrypt_generic_init($cipher, $key, $iv);
        $encrypted = mcrypt_generic($cipher, $cc);
        mcrypt_generic_deinit($cipher);

        return base64_encode($encrypted);
    }
757513
public function parse($string) {
        $cookie = $this->createCookie();
        $cookie->setSecure(false);
        $cookie->setHttpOnly(false);

        $parts = explode(';', $string);

        foreach ($parts as $part) {
            $part = trim($part);
            $this->parseFlags($cookie, $part);
            $this->parseProperties($cookie, $part);
        }

        return $cookie;
    }