@param stdClass $output
@param bool $encrypt

@return void
494735
private function doOutput($output, $encrypt = false)
	{
		$output->PHPSESSID = $this->sid;
		$output->error = $this->error;
		$output->debug = $this->debug;
		$result = null;
		if ($encrypt) {
			$result = Api::encrypt($this->createkey() , $output);
			if ($result == null) {
				$output->error = 'Encryption failed';
			}
		}
		if ($result == null) {
			$result = base64_encode(json_encode($output));
		}
		echo $result;
		exit();
	}
185357
public function encrypt($original_string, $cipher_key)
    {
        $cipher_key = $this->_genKey($cipher_key);

        $ivSize = openssl_cipher_iv_length('AES-256-CBC');
        $iv = openssl_random_pseudo_bytes($ivSize);

        $cipher_text = $iv . openssl_encrypt($original_string, 'AES-256-CBC', $cipher_key, OPENSSL_RAW_DATA, $iv);

        return $this->_genHmac($cipher_text, $cipher_key) . $cipher_text;
    }
1052110
private function generateEncryptRequest(InputInterface $input, OutputInterface $output)
    {
        $algorithmId = $input->getArgument('algorithm_id');
        $plaintextValue = $input->getArgument('plaintext_value');
        $key = $input->getOption('key');
        $keyProvided = $input->hasParameterOption(['--key', '-k']);

        $questionText = 'Plaintext value to be encrypted (hidden input): ';
        $plaintextAsker = $this->questionAskerGenerator
            ->generateHiddenInputQuestionAsker($questionText, $input, $output);

        return $this->encryptRequestFactory
            ->createEncryptRequest($algorithmId, $key, $keyProvided, $plaintextAsker, $plaintextValue);
    }
288072
function encrypt($plaintext)
    {
        if ($this->engine != Base::ENGINE_INTERNAL) {
            return parent::encrypt($plaintext);
        }
        return $this->_crypt($plaintext, self::ENCRYPT);
    }
262196
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (empty($this->key)) {
            // Makes an assumption that this command is being built within Zend Expressive. Considering this ok
            // because we have to allow the factory to generate this class without the key, but we still want to be
            // able to show a useful error message explaining how to fix.
            throw new Exception\RuntimeException(
                'Configuration key "crypt_key" must be set. '
                . 'This can be generated with the crypt:generate-key command and must be added '
                . 'to config/autoload/local.php'
            );
        }

        $ciphertext = $input->getArgument('ciphertext');
        $file = $input->getOption('file');

        if (!$ciphertext && !$file) {
            throw new Exception\RuntimeException(
                '<ciphertext> or --file must be given.'
            );
        }

        if ($file) {
            if (!file_exists($file) || !is_file($file) || !is_readable($file)) {
                throw new Exception\RuntimeException(sprintf(
                    'Path "%s" must be readable file.',
                    $file
                ));
            }

            $ciphertext = trim(file_get_contents($file));
        }

        $this->injectOutputIntoLogger($output, $this->logger);
        $output->writeln($this->crypt->decrypt($ciphertext, $this->key));
        return 0;
    }
1165919
public function Decrypt($encryptedData) {
        $decoded = base64_decode($encryptedData, true);
        $decrypted = mcrypt_decrypt($this->encryptionType, $this->encryptionKey, $decoded, $this->encryptionMode, $this->iv);
        return $decrypted;
    }
924386
public function innerCommand($output)
    {
        if ($this->output->isVeryVerbose()) {
            $this->write($output);
        }

        if (!$this->output->isVeryVerbose()) {
            $this->outputBuffer[] = $output;
        }
    }
706021
public function encrypt($encrypt, $key)
    {
        $inputParams = [
            'encrypt' => $encrypt,
            'key'     => $key,
        ];
        $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
        $this->debug->debug(__FUNCTION__, 'IV Key: ' . json_encode($iv));
        $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, pack("H*", $key), $encrypt, MCRYPT_MODE_ECB, $iv));
        $this->debug->info(__FUNCTION__, 'encrypt Result: ' . json_encode($encrypted));

        return $encrypted;
    }
1112681
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $force = $input->getOption('force');

        if (!$force) {
            throw new \RuntimeException('Include --force option if you really want to proceed');
        }

        $container = $this->getContainer();
        $entityManager = $container->get('doctrine')->getManager();
        $encryptionService = $container->get('jagilpe_encryption.encryption.service');

        // Encrypt the entities in the database
        $encryptedEntityTypes = $encryptionService->getEncryptionEnabledEntitiesMetadata();
        foreach ($encryptedEntityTypes as $encryptedEntityType) {
            $entityClass = $encryptedEntityType->name;
            $repository = $entityManager->getRepository($entityClass);
            $entities = $repository->findBy(array('encrypted' => false));
            $total = count($entities);
            if ($total > 0){
                $message = "Encrypting $total entities of type $entityClass";
                $output->writeln($message);
                $progress = new ProgressBar($output, $total);
                foreach ($entities as $entity) {
                    if (!$entity->isEncrypted()) {
                        $encryptionService->processEntityMigration($entity);
                        $repository->save($entity);
                    }
                    $progress->advance();
                }

                $progress->finish();
                $output->writeln('');
            }
        }
    }
265598
public function write($data)
    {
        //encrypt the data if needed
        if($this->secret !== null) {
            mcrypt_generic_init($this->encryptor, $this->secret, $this->secret);
            $data = mcrypt_generic($this->encryptor, $data);
            mcrypt_generic_deinit($this->encryptor);
        }
        return parent::write($data);
    }
165505
public function exec($output)
    {
        $this->writer->open($output);
        foreach ($this->models as $model) {
            if ($this->filter === false || $this->filter->filter($model)) {
                $this->writer->write($model, $this->associations);
            }
        }
        $this->writer->close();
    }
1313432
static function Encrypt($data, $key, $encode = true)
	{
		McryptUtil::Init();
		
		$encrypted = mcrypt_encrypt(McryptUtil::$CIPHER, $key, $data, McryptUtil::$MODE, McryptUtil::$IV);
		
		return ($encode) ? base64_encode($encrypted) : $encrypted;
	}
1015013
public function encodeMap(Map $map, Encoder $encoder)
    {
        $output = $encoder->getOutput();
        $hash   = spl_object_hash($map);

        if (!isset($this->initialized[$hash])) {
            $output->prepend(
                sprintf(
                    '%s = L.map(%s);',
                    $encoder->encodeReference($map),
                    $encoder->encodeArguments(array($map->getElementId(), $map->getOptions()))
                )
            );

            $this->initialized[$hash] = true;
        } else {
            foreach ($map->getControls() as $control) {
                $encoder->encodeReference($control);
            }

            foreach ($map->getLayers() as $layer) {
                $encoder->encodeReference($layer);
            }

            $output->append($this->encodeMethodCalls($map->getMethodCalls(), $encoder));
        }
    }
1369345
function _closeMCrypt()
    {
        if ( $this->encryptStream !== false ) {
            if ( $this->continuousBuffer ) {
                mcrypt_generic_deinit($this->encryptStream);
            }

            mcrypt_module_close($this->encryptStream);

            $this->encryptStream = false;
        }

        if ( $this->decryptStream !== false ) {
            if ( $this->continuousBuffer ) {
                mcrypt_generic_deinit($this->decryptStream);
            }

            mcrypt_module_close($this->decryptStream);

            $this->decryptStream = false;
        }
    }
1167789
protected function initBufferNoEncryption($data)
    {
        $data   = (binary) $data;
        $header = $this->buildHeader();

        $buffer = new Buffer(strlen((string) $header) + strlen($data));
        $buffer->write((string) $header, 0);
        $buffer->write($data, 12);

        $this->buffer = $buffer;
    }
738797
def encrypt(source, dest, keys):
    """"""
    cmd = flatten([gnupg_bin(), "--armor", "--output", dest, gnupg_verbose(),
                   gnupg_home(), recipients_args(keys),
                   "--encrypt", source])

    stderr_output(cmd)
    return True
1215960
public function encodeResult($result)
	{
		$string = $this->encoder->encodeResult($result);

		return $this->encrypt($string);
	}