Decrypts string with given key.

@param string $string string
@param string $key    key

@return string
775511
public function decrypt($string, $key)
    {
        $key = $this->_formKey($key, $string);

        $string = substr($string, 3);
        $string = str_replace('!', '=', $string);
        $string = base64_decode($string);
        $string = $string ^ $key;

        return substr($string, 2, -2);
    }
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;
    }
363314
public static function decrypt($data = '', $key = ''): string
    {
        $key = md5(empty($key) ? \Yii::$app->getRequest()->cookieValidationKey : $key);
        $data = str_replace(['-', '_'], ['+', '/'], $data);
        $mod4 = strlen($data) % 4;
        if ($mod4) {
            $data .= substr('====', $mod4);
        }
        $data = base64_decode($data);
        $expire = substr($data, 0, 10);
        $data = substr($data, 10);
        
        if ($expire > 0 && $expire < time()) {
            return '';
        }
        $x = 0;
        $len = strlen($data);
        $l = strlen($key);
        $char = $str = '';
        
        for ($i = 0; $i < $len; $i++) {
            if ($x == $l) {
                $x = 0;
            }
            $char .= substr($key, $x, 1);
            $x++;
        }
        
        for ($i = 0; $i < $len; $i++) {
            if (ord(substr($data, $i, 1)) < ord(substr($char, $i, 1))) {
                $str .= chr((ord(substr($data, $i, 1)) + 256) - ord(substr($char, $i, 1)));
            } else {
                $str .= chr(ord(substr($data, $i, 1)) - ord(substr($char, $i, 1)));
            }
        }
        
        return base64_decode($str);
    }
329007
public static function simpleEncode($string, $passkey = null)
    {
        $key = $passkey;
        if (!isset($passkey) || empty($passkey)) {
            $key = self::generateServerSpecificHash();
        }

        $result = '';
        for ($i = 0; $i < strlen($string); $i++) {
            $char = substr($string, $i, 1);
            $keychar = substr($key, ($i % strlen($key)) - 1, 1);
            $char = chr(ord($char) + ord($keychar));
            $result .= $char;
        }

        return base64_encode($result);
    }
1157031
public static function blazeEncrypt (string $string) : string
    {
        $cryptKey           = 'qJB0rGtIn5UB1xG03efyCp';
        return base64_encode(mcrypt_encrypt(
        	MCRYPT_RIJNDAEL_256, md5($cryptKey), $string, MCRYPT_MODE_CBC, md5(md5($cryptKey)))
        );
    }
566552
protected function decrypt($key, $text)
    {
        $td = mcrypt_module_open('blowfish', '', 'ecb', '');
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key , $iv);

        $data = mdecrypt_generic($td, $text);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);

        $data = $this->pkcs5_unpad($data);

        return $data;
    }
1317703
public function decrypt($text): string
    {
        $length = strlen($text);
        $plain = '';
        for ($iteration = 0; $iteration < $length; $iteration += 8) {
            $aBlock = $this->asc2int(substr($text, $iteration, 4));
            $bBlock = $this->asc2int(substr($text, $iteration + 4, 4));
            list($aBlock, $bBlock) = $this->bfDecrypt($aBlock, $bBlock);
            $plain .= $this->int2asc($aBlock) . $this->int2asc($bBlock);
        }
        return $plain;
    }
899230
protected static function encode($string, $key)
    {
        for ($i = 0; $i < strlen($key); $i++) {
            $char   = $key[$i];
            $string = str_replace("\\{$char}", "%{$i}", $string);
        }

        return $string;
    }
1275596
public function read($key, $ciphertext)
    {
        $ciphertext = strval($ciphertext);
        return (strlen($key) && strlen($ciphertext))
            ? $this->_getCipherOb($key)->decrypt($ciphertext)
            : '';
    }
563937
public static function decrypt($data, $key = self::KEY, $iv = self::IV)
    {
        return openssl_decrypt(base64_decode($data), self::MOD, $key, OPENSSL_RAW_DATA, $iv);
    }
436993
function decrypt($ciphertext)
    {
        if ($this->engine == self::ENGINE_OPENSSL) {
            $temp = $this->key;
            $this->key = $this->orig_key;
            $result = parent::decrypt($ciphertext);
            $this->key = $temp;
            return $result;
        }

        return parent::decrypt($ciphertext);
    }
1137896
public function decrypt(string $ciphertext, string $key): string
    {
        $numMatches = preg_match_all('%^ENC\[([^,]+),(.*)\]$%', $ciphertext, $matches);
        if (0 == $numMatches) {
            throw new Exception\RuntimeException(sprintf(
                "\$ciphertext must be in the format ENC[\$encryptionType,\$ciphertext].\n"
                . "Provided ciphertext: %s",
                $ciphertext
            ));
        }

        $encryptionType = $matches[1][0];
        $ciphertext = $matches[2][0];

        switch ($encryptionType) {
            case self::ENCRYPTION_TYPE_DEFUSE_PHP_ENCRYPTION:
                $key = Key::loadFromAsciiSafeString($key);
                return Crypto::decrypt($ciphertext, $key);

            default:
                throw new Exception\RuntimeException(sprintf(
                    'Unsupported encryption type "%s". Supported encryption types: "%s".',
                    $encryptionType,
                    implode('", "', [self::ENCRYPTION_TYPE_DEFUSE_PHP_ENCRYPTION])
                ));
        }


    }
2052
public function decrypt(string $value, string $key, bool $base64 = false)
    {
        if ($base64) {
            $value = base64_decode($value);
        }
        $ret = $this->decryptBinary($value, $key);
        return unserialize($ret);
    }
539927
public function encrypt($string)
    {
        $numbers = [];
        $letters = str_split($this->crypt->encrypt($string));

        $i = 0;
        foreach ($letters as $letter) {
            if ($number = array_search($letter, static::$charactersMap)) {
                if ($i == 20) {
                    $number = $number . PHP_EOL;
                    $i = 0;
                }

                $numbers[] = $number;

                $i++;
            }
        }

        return implode(' ', $numbers);
    }
654837
public function encryptString($algo, $string, $key = null)
    {     
        if (!empty($algo) && !empty($string)) {   
            if ($key == null) {
                $ctx = hash_init($algo);
            } else {
                $ctx = hash_init($algo, HASH_HMAC, $key);
                hash_update($ctx, $string);
            }
            return hash_final($ctx);
        }
        return false;
    }
786410
public function decrypt(string $data) {
        $keyHash = md5(Config::getConfig()->encrypt->key);
        $key = substr($keyHash, 0, mcrypt_get_key_size(self::$cipher, self::$mode));
        $iv = substr($keyHash, 0, mcrypt_get_block_size(self::$cipher, self::$mode));
        return mcrypt_decrypt(self::$cipher, $key, base64_decode($data), self::$mode, $iv);
    }
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);
  }