Encrypts a block

@see Crypt_Base::_encryptBlock()
@see Crypt_Base::encrypt()
@access private
@param string $in
@return string
971301
function _encryptBlock($in)
    {
        list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in));
        $keys = $this->keys;
        $limit = 20;
        $actions = array($limit => 44, 44 => 64);
        $j = 0;

        for (;;) {
            // Mixing round.
            $r0 = (($r0 + $keys[$j++] + ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1;
            $r0 |= $r0 >> 16;
            $r1 = (($r1 + $keys[$j++] + ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2;
            $r1 |= $r1 >> 16;
            $r2 = (($r2 + $keys[$j++] + ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3;
            $r2 |= $r2 >> 16;
            $r3 = (($r3 + $keys[$j++] + ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5;
            $r3 |= $r3 >> 16;

            if ($j === $limit) {
                if ($limit === 64) {
                    break;
                }

                // Mashing round.
                $r0 += $keys[$r3 & 0x3F];
                $r1 += $keys[$r0 & 0x3F];
                $r2 += $keys[$r1 & 0x3F];
                $r3 += $keys[$r2 & 0x3F];
                $limit = $actions[$limit];
            }
        }

        return pack('vvvv', $r0, $r1, $r2, $r3);
    }
1090800
public function encrypt($value)
    {
        $iv = substr(md5(random_bytes(16)), 0, 16);
        $encrypted = openssl_encrypt($value, $this->encoding, $this->password, null, $iv);

        return $this->url_encode($iv.$encrypted);
    }
288072
function encrypt($plaintext)
    {
        if ($this->engine != Base::ENGINE_INTERNAL) {
            return parent::encrypt($plaintext);
        }
        return $this->_crypt($plaintext, self::ENCRYPT);
    }
469944
public function encrypt($input)
    {
        if (! $input) {
            return $input;
        }

        $methods = $this->getEncryptionMethods();
        $method  = reset($methods);
        $mkey    = key($methods);

        if ('mcrypt' == $method) {
            $result = $this->encryptMcrypt($input);
        } elseif ('null' == $method) {
            $result = $input;
        } else {
            $result = $this->encryptOpenSsl($input, $method);
        }

        return ":$mkey:" . base64_encode($result);
    }
1352776
function encryptSimple($data) {
		$result = '';
		for($i=0; $i<strlen($data); $i++) {
			$char = substr($data, $i, 1);
			$keychar = substr($this->encPassword, ($i % strlen($this->encPassword))-1, 1);
			$char = chr(ord($char)+ord($keychar));
			$result.=$char;
		}
		return str_replace(array('+', '/'), array('-', '_'),base64_encode($result));
	}
721922
public function encrypt($data) {
        $data = trim($data);
        $str = $this->pkcs7Pad($data, $this->blockSize);
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,MCRYPT_MODE_CBC),1);
        $encrypt_str =  mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, $str, MCRYPT_MODE_CBC);
        return base64_encode($encrypt_str);
    }
467723
public function decrypt($encrypted) {
    return trim(
                mcrypt_decrypt(
                               MCRYPT_RIJNDAEL_256,
                               $this->password,
                               base64_decode($encrypted),
                               MCRYPT_MODE_ECB,
                               mcrypt_create_iv(
                                                mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB),
                                                MCRYPT_RAND
                                                )
                               )
                );
  }
700251
protected function encrypt($token)
    {
        // Serialize the token object
        $token = serialize($token);
        
        // Encrypt the token if there is an Encrypter instance
        if ($this->encrypter instanceof Encrypter) {
            $token = $this->encrypter->encrypt($token);
        }
        
        // Return the token
        return $token;
    }
995831
protected function _encrypt(string $kek, string $block): string
    {
        $str = openssl_encrypt($block, $this->_cipherMethod(), $kek,
            OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING);
        if (false === $str) {
            throw new \RuntimeException(
                "openssl_encrypt() failed: " . $this->_getLastOpenSSLError());
        }
        return $str;
    }
216092
function encrypt($plaintext)
    {
        if ($this->engine == self::ENGINE_OPENSSL) {
            $temp = $this->key;
            $this->key = $this->orig_key;
            $result = parent::encrypt($plaintext);
            $this->key = $temp;
            return $result;
        }

        return parent::encrypt($plaintext);
    }
122040
private function decryptPrivate($data)
    {
        if (!openssl_private_decrypt($data, $decrypted, $this->key, $this->cryptParams['padding'])) {
            throw new Exception('Failure decrypting Data (openssl private) - ' . openssl_error_string());
        }
        return $decrypted;
    }
818143
protected function encrypt($value)
    {
        return $this->getCryptService()->encrypt(serialize($value), $this->getSecurity()->getPrivateKey());
    }
1315800
public function getCrypt(): ?Encrypter
    {
        if (!$this->hasCrypt()) {
            $this->setCrypt($this->getDefaultCrypt());
        }
        return $this->crypt;
    }
437019
function _encryptBlock($in)
    {
        $state = array();
        $words = unpack('N*word', $in);

        $w = $this->w;
        $t0 = $this->t0;
        $t1 = $this->t1;
        $t2 = $this->t2;
        $t3 = $this->t3;
        $Nb = $this->Nb;
        $Nr = $this->Nr;
        $c = $this->c;

        // addRoundKey
        $i = 0;
        foreach ($words as $word) {
            $state[] = $word ^ $w[0][$i++];
        }

        // fips-197.pdf#page=19, "Figure 5. Pseudo Code for the Cipher", states that this loop has four components - 
        // subBytes, shiftRows, mixColumns, and addRoundKey. fips-197.pdf#page=30, "Implementation Suggestions Regarding 
        // Various Platforms" suggests that performs enhanced implementations are described in Rijndael-ammended.pdf.
        // Rijndael-ammended.pdf#page=20, "Implementation aspects / 32-bit processor", discusses such an optimization.
        // Unfortunately, the description given there is not quite correct.  Per aes.spec.v316.pdf#page=19 [1], 
        // equation (7.4.7) is supposed to use addition instead of subtraction, so we'll do that here, as well.

        // [1] http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.v316.pdf
        $temp = array();
        for ($round = 1; $round < $Nr; $round++) {
            $i = 0; // $c[0] == 0
            $j = $c[1];
            $k = $c[2];
            $l = $c[3];

            while ($i < $this->Nb) {
                $temp[$i] = $t0[$state[$i] & 0xFF000000] ^ 
                            $t1[$state[$j] & 0x00FF0000] ^ 
                            $t2[$state[$k] & 0x0000FF00] ^ 
                            $t3[$state[$l] & 0x000000FF] ^ 
                            $w[$round][$i];
                $i++;
                $j = ($j + 1) % $Nb;
                $k = ($k + 1) % $Nb;
                $l = ($l + 1) % $Nb;
            }

            for ($i = 0; $i < $Nb; $i++) {
                $state[$i] = $temp[$i];
            }
        }

        // subWord
        for ($i = 0; $i < $Nb; $i++) {
            $state[$i] = $this->_subWord($state[$i]);
        }

        // shiftRows + addRoundKey
        $i = 0; // $c[0] == 0
        $j = $c[1];
        $k = $c[2];
        $l = $c[3];
        while ($i < $this->Nb) {
            $temp[$i] = ($state[$i] & 0xFF000000) ^ 
                        ($state[$j] & 0x00FF0000) ^ 
                        ($state[$k] & 0x0000FF00) ^ 
                        ($state[$l] & 0x000000FF) ^
                         $w[$Nr][$i];
            $i++;
            $j = ($j + 1) % $Nb;
            $k = ($k + 1) % $Nb;
            $l = ($l + 1) % $Nb;
        }
        $state = $temp;

        array_unshift($state, 'N*');

        return call_user_func_array('pack', $state);
    }
657305
protected function decrypt($encryptedString)
    {
        $iv = mcrypt_create_iv(mcrypt_get_iv_size($this->cipher, $this->cipherMode), MCRYPT_RAND);

        return mcrypt_decrypt($this->cipher, $this->secretKey, $encryptedString, $this->cipherMode, $iv);
    }
910024
public function encrypt($data)
    {
        if (!$this->iv || $this->autoIvUpdate) {
            $this->generateIv();
        }

        $output = openssl_encrypt($data, $this->cipher, $this->secret, OPENSSL_RAW_DATA, $this->iv);

        if ($this->formatter) {
            $output = $this->formatter->format($this->iv, $output);
        }

        return $output;
    }
809792
private function encryptBlock($input, $key)
    {
        if (!$input && !$key) {
            return '';
        }

        $this->prepareCipher($key);
        $result = mcrypt_generic($this->mcrypt, $input);
        mcrypt_generic_deinit($this->mcrypt);

        return $result;
    }