Returns decrypted data if using symmetric key, otherwise returns $this for chaining to with() method
@param $subject Data/string to encrypt
@return $this (with private key) or decrypted data (with symmetric key)
199084
public function decrypt($subject)
    {

        if ($this->key->getType() == CryptoKey::TYPE_SYMMETRIC) {
            // Symmetric? This is easy...
            return parent::decrypt($subject);
        }

        $splitSubject = explode('|', $subject);
        if (sizeof($splitSubject) != 2) {
            throw new Exception('Not a valid ciphertext for CryptoPackage, try the Crypto class');
        }

        $this->action = self::ACTION_DECRYPT;
        $this->subject = base64_decode($splitSubject[0]);
        $this->secondSubject = base64_decode($splitSubject[1]);

        return $this;
    }
871993
public static function getSubjectIdentity($subject)
    {
        if ($subject instanceof SubjectIdentityInterface) {
            return $subject;
        }

        if (\is_string($subject)) {
            return SubjectIdentity::fromClassname($subject);
        }

        if (\is_object($subject)) {
            return SubjectIdentity::fromObject($subject);
        }

        throw new UnexpectedTypeException($subject, SubjectIdentityInterface::class.'|object|string');
    }
179633
private function decryptSymmetricKeyWithSystemKey($entity)
    {
        /** @var SymmetricKey $encryptedKey */
        $encryptedKey = $entity->getKey();
        $decryptedKey = null;

        $systemKey = $encryptedKey->getSystemKey();
        $privateKey = $this->keyStore->getPrivateMasterKey();

        if ($systemKey) {
            $systemKey = base64_decode($systemKey);
            $decryptedKey = $this->cryptographyProvider->decryptWithPrivateKey($systemKey, $privateKey);
        }

        return $decryptedKey;
    }
1140110
private function getMessage(string $subject, string $message): \Swift_Message
    {
        $messageObject = new \Swift_Message($subject, $message);
        $messageObject
            ->setFrom([$this->config('mailer.sender_email') => $this->config('mailer.sender_name')])
            ->setTo($this->config('mailer.recipients'))
        ;

        return $messageObject;
    }
192483
public function subject($subject) {

		if(false === is_string($subject)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($subject)), E_USER_ERROR);
		}

		$this -> subject = $subject;

		return $this;
	}
1126130
protected function _encrypt($decrypted = []) {
		$vector = $this->_config['vector'];
		$secret = $this->_hashSecret($this->_config['secret']);

		mcrypt_generic_init(static::$_resource, $secret, $vector);
		$encrypted = mcrypt_generic(static::$_resource, serialize($decrypted));
		mcrypt_generic_deinit(static::$_resource);

		return base64_encode($encrypted) . base64_encode($vector);
	}
974541
public function setSubject($subject): self
	{
		$this->message->setSubject($this->translator ? $this->translator->translate($subject) : (string) $subject);
		return $this;
	}
1175657
private function decryptWithPrivateKey($cipher, OpenSslRsaKey $privateKey)
    {
        $decrypted = '';
        $key = openssl_pkey_get_private($privateKey->getKeyString());
        if (openssl_private_decrypt($cipher, $decrypted, $key, $this->paddingAlgorithm) === false) {
            // Fallback for data that was encrypted with old default OPENSSL_PKCS1_PADDING
            if ($this->paddingAlgorithm !== OPENSSL_PKCS1_PADDING) {
                if (openssl_private_decrypt($cipher, $decrypted, $key, OPENSSL_PKCS1_PADDING) !== false) {
                    return $decrypted;
                }
            }
            $openSslErrors = [];
            while (($errorMessage = openssl_error_string()) !== false) {
                $openSslErrors[] = $errorMessage;
            }
            throw new SecurityException(sprintf('Decryption failed, OpenSSL error: %s', implode(chr(10), $openSslErrors)), 1556609762);
        }

        return $decrypted;
    }
728728
public function getClientKey($client_id, $subject)
    {
        if (isset($this->jwt[$client_id])) {
            $jwt = $this->jwt[$client_id];
            if ($jwt) {
                if ($jwt["subject"] == $subject) {
                    return $jwt["key"];
                }
            }
        }

        return null;
    }
656762
public function decrypt($encrypted, $privateKey)
    {
        $rsa = new RSA();
        $rsa->loadKey($privateKey);

        return $rsa->decrypt($encrypted);
    }
638787
public function response(Response $response, CryptographyEngine $cryptographyEngine)
	{
		$decryptedResponse = new DecryptedCommandResponse($response);

		$decryptedResponse->assignCryptographyEngine($cryptographyEngine, $this->email);

		return $decryptedResponse;
	}
994489
protected function doDecrypt($data, $key, $iv)
    {
        return openssl_decrypt($data, $this->getMethod(), $key, OPENSSL_RAW_DATA, $iv);
    }
388317
public function decorate($subject)
    {
        foreach ($subject as $key => $atom) {
            $subject[$key] = $this->autoPresenter->decorate($atom);
        }

        return $subject;
    }
1131518
public function decrypt(string $encrypted)
    {
        $decryptParam = new DecryptParameter([
            'shopLogin' => $this->shopLogin,
            'CryptedString' => $encrypted,
        ]);

        if ($this->apiKey) {
            $decryptParam->apikey = $this->apiKey;
        }

        return $this->encryptClient->decrypt($decryptParam);
    }
637407
public function setSubject($subject)
    {
        $this->_subject = $this->encodeUtf8(
            $this->filterOther((string) $subject)
        );
        return $this;
    }
638174
public function encrypt()
    {
        if ($this->encryption == 'XOR') {
            $this->encrypted_data = $this->simplexor();
        } elseif ($this->encryption == 'MCRYPT') {
            $this->encrypted_data = $this->mcrypt();
        }

        return $this;
    }
21863
function decrypt($encryptedText)
    {
        $parts = explode(':', $encryptedText);

        if (count($parts) != 2) {
            throw new DecryptionException();
        }

        $main = base64_decode($parts[0]);
        $iv = base64_decode($parts[1]);
        return openssl_decrypt($main, $this->method, $this->key, $this->options, $iv);
    }