Returns the options for the encryption depending on the encryption type

@param string $encType
@return int
@throws EncryptionException
964986
private function getEncryptionOptions($encType = CryptographyProviderInterface::PROPERTY_ENCRYPTION)
    {
        switch ($encType) {
            case CryptographyProviderInterface::PROPERTY_ENCRYPTION:
            case CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION:
                return 0;
            case CryptographyProviderInterface::FILE_ENCRYPTION:
                return OPENSSL_RAW_DATA;
            default:
                throw new EncryptionException('Encryption type not supported: '.$encType);
        }
    }
689842
protected static function dispositionType( $mimeType )
    {
        $ini = eZINI::instance( 'file.ini' );

        $mimeTypes = $ini->variable( 'PassThroughSettings', 'ContentDisposition', array() );
        if ( isset( $mimeTypes[$mimeType] ) )
        {
            return $mimeTypes[$mimeType];
        }

        return $ini->variable( 'PassThroughSettings', 'DefaultContentDisposition' );
    }
287387
static public function getType($strType){
		//convert reserved names to the actual objects
		$arrReservere = array(
			'array' => 'ArrayObject',
			'bool' => 'BooleanObject',
			'boolean' => 'BooleanObject',
			'datetime' => 'DateTimeObject',
			'dictionary' => 'DictionaryObject',
			'enum' => 'EnumObject',
			'id' => 'IdObject',
			'int' => 'IntObject',
			'float' => 'FloatObject',
			'string' => 'StringObject',
			'resource' => 'ResourceObject',
			'object' => 'ObjectObject',
			'objectarray' => 'ObjectArrayObject',
			'number' => 'NumberObject',
			'numeric' => 'NumberObject',
			'fixeddictionary' => 'FixedDictionaryObject'
		);

		if(array_key_exists(strtolower($strType), $arrReservere)){
			$strType = $arrReservere[strtolower($strType)];
		}

		$strType = 'Frozensheep\\Synthesize\\Type\\'.ucfirst($strType);

		return $strType;
	}
1000063
public function HasClassEnum($type)
    {   
        $components = $this->GetComponents($type);
        
        if($components->HasClass())
        {
            foreach($this->headers as $header_object)
            {
                if($components->HasNamespace())
                {
                    if(
                        isset(
                            $header_object->namespaces[$components->namespace]
                                ->classes[$components->class]
                                ->enumerations[$components->type]
                        )
                    )
                        return $header_object->namespaces[$components->namespace]
                            ->classes[$components->class]
                            ->enumerations[$components->type]
                        ;
                }
                else
                {
                    if(
                        isset(
                            $header_object->namespaces["\\"]
                                ->classes[$components->class]
                                ->enumerations[$components->type]
                        )
                    )
                        return $header_object->namespaces["\\"]
                            ->classes[$components->class]
                            ->enumerations[$components->type]
                        ;
                }
            }
        }
        
        return null;
    }
744133
public function getEncoderForType(string $type): IEncoder
    {
        $normalizedType = self::normalizeType($type);

        if (isset($this->encodersByType[$normalizedType])) {
            return $this->encodersByType[$normalizedType];
        }

        if (class_exists($type)) {
            if ($this->defaultObjectEncoder === null) {
                throw new OutOfBoundsException('No default object encoder is registered');
            }

            return $this->defaultObjectEncoder;
        }

        if ($this->defaultScalarEncoder === null) {
            throw new OutOfBoundsException('No default scalar encoder is registered');
        }

        return $this->defaultScalarEncoder;
    }
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);
    }
917607
protected function convertType(string $type) : int
    {
        switch ($type) {
            case LogLevel::EMERGENCY:
                return LOG_EMERG;
            case LogLevel::ALERT:
                return LOG_ALERT;
            case LogLevel::CRITICAL:
                return LOG_CRIT;
            case LogLevel::ERROR:
                return LOG_ERR;
            case LogLevel::WARNING:
                return LOG_WARNING;
            case LogLevel::NOTICE:
                return LOG_NOTICE;
            case LogLevel::INFO:
                return LOG_INFO;
            case LogLevel::DEBUG:
                return LOG_DEBUG;
            default:
                throw new \InvalidArgumentException(sprintf("Invalid log type '%s'", $type));
        }
    }
1152523
public function get_type_value($type = null, $type_cast = false)
    {

        if (empty($type)) return "null";

        if (strpos(strtolower($type), 'int') !== false) {
            return ($type_cast) ? '(int)' : 0;
        }

        if (strpos(strtolower($type), 'float') !== false) {
            return ($type_cast) ? '(float)' : 0;
        }

        if (strpos(strtolower($type), 'char') !== false) {
            return ($type_cast) ? '(string)' : "''";
        }

        if (strpos(strtolower($type), 'enum') !== false) {
            return ($type_cast) ? '(string)' : "''";
        }

        if (strpos(strtolower($type), 'dec') !== false) {
            return ($type_cast) ? '(float)' : 0;
        }

        if (strpos(strtolower($type), 'text') !== false) {
            return ($type_cast) ? '(string)' : "''";
        }

        if (strpos(strtolower($type), 'bit') !== false) {
            return ($type_cast) ? '(string)' : "''";
        }

        if (strpos(strtolower($type), 'bool') !== false) {
            return ($type_cast) ? '(boolean)' : "false";
        }

        if (strpos(strtolower($type), 'datetime') !== false) {
            return ($type_cast) ? '(string)' : "'0000-00-00 00:00:00'";
        }

        if (strpos(strtolower($type), 'date') !== false) {
            return ($type_cast) ? '(string)' : "'0000-00-00'";
        }

        if (strpos(strtolower($type), 'year') !== false) {
            return ($type_cast) ? '(string)' : "'0000'";
        }

        if (strpos(strtolower($type), 'time') !== false) {
            return ($type_cast) ? '(int)' : 0;
        }

        if (strpos(strtolower($type), 'double')) {
            return ($type_cast) ? '(double)' : 0;
        }

        return "null";
    }
328958
private function checkType($type)
    {
        $isInType = true;

        foreach ($this->getKeys() as $key) {
            if (gettype($key) !== $type) {
                $isInType = false;
                break;
            }
        }

        return $isInType;
    }
1163547
public function encryptPacket(string $packet, string $initialisationVector) : string {
        $mcryptCipher = $this->translateCipher($this->encryptionCipher);
        $len = mcrypt_get_iv_size($mcryptCipher, $this->encryptionMode);
        if (false === is_int($len)) {
            throw new EncryptionException('Cannot figure out length of ' .
            'initialisation vector for encryption cipher ' .
            $this->encryptionCipher
            );
        }
        $civ = substr($initialisationVector, 0, $len);
        /*
         * I encountered a problem with DES that the package won't encrypt 
         * properly if the password is longer than the iv length, for whatever
         * reason. 
         */
        $pass = $this->encryptionMode === self::ENCRYPT_DES 
                ? substr($this->encryptionPassword, 0, $len)
                : $this->encryptionPassword
        ;
        $encryptedPackage = mcrypt_encrypt($mcryptCipher, $pass, $packet, $this->encryptionMode, $civ);
        if (false === $encryptedPackage) {
            throw new EncryptionException('Failed to encrypt package. ' .
                    'Check if your password is long enough for the cipher you chose'
            );
        }
        return $encryptedPackage;
    }
1353444
public function getFieldBindType($type)
    {
        if (0 === strpos($type, 'set') || 0 === strpos($type, 'enum')) {
            $bind = PDO::PARAM_STR;
        } elseif (preg_match('/(double|float|decimal|real|numeric)/is', $type)) {
            $bind = self::PARAM_FLOAT;
        } elseif (preg_match('/(int|serial|bit)/is', $type)) {
            $bind = PDO::PARAM_INT;
        } elseif (preg_match('/bool/is', $type)) {
            $bind = PDO::PARAM_BOOL;
        } else {
            $bind = PDO::PARAM_STR;
        }

        return $bind;
    }
112465
public function setEncoding(int $enc_type)
    {
        static $enc_type_list;
        if (null === $enc_type_list) {
            $enc_type_list = [
                self::RFC1738_ENCODING => 1,
                self::RFC3986_ENCODING => 1,
                self::RFC3987_ENCODING => 1,
                self::NO_ENCODING => 1,
            ];
        }

        if (!isset($enc_type_list[$enc_type])) {
            throw new InvalidArgumentException(sprintf('Unsupported or Unknown Encoding: %s', $enc_type));
        }

        $this->enc_type = $enc_type;
    }
981811
function _encryptBlock($in)
    {
        $p = $this->bctx["p"];
        // extract($this->bctx["sb"], EXTR_PREFIX_ALL, "sb"); // slower
        $sb_0 = $this->bctx["sb"][0];
        $sb_1 = $this->bctx["sb"][1];
        $sb_2 = $this->bctx["sb"][2];
        $sb_3 = $this->bctx["sb"][3];

        $in = unpack("N*", $in);
        $l = $in[1];
        $r = $in[2];

        for ($i = 0; $i < 16; $i+= 2) {
            $l^= $p[$i];
            $r^= $this->safe_intval(($this->safe_intval($sb_0[$l >> 24 & 0xff]  + $sb_1[$l >> 16 & 0xff]) ^
                  $sb_2[$l >>  8 & 0xff]) +
                  $sb_3[$l       & 0xff]);

            $r^= $p[$i + 1];
            $l^= $this->safe_intval(($this->safe_intval($sb_0[$r >> 24 & 0xff]  + $sb_1[$r >> 16 & 0xff]) ^
                  $sb_2[$r >>  8 & 0xff]) +
                  $sb_3[$r       & 0xff]);
        }
        return pack("N*", $r ^ $p[17], $l ^ $p[16]);
    }
1045625
public function decrypt($encrypted)
    {
        try {
            $iv = substr($this->key, 0, 16);
            $decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', substr($this->key, 0, 32), OPENSSL_ZERO_PADDING, $iv);
        } catch (Exception $e) {
            return [ErrorCode::$DecryptAESError, null];
        }
        try {
            $pkcEncoder = new PKCS7Encoder();
            $result = $pkcEncoder->decode($decrypted);
            if (strlen($result) < 16) {
                return [ErrorCode::$DecryptAESError, null];
            }
            $content = substr($result, 16, strlen($result));
            $len_list = unpack("N", substr($content, 0, 4));
            $xml_len = $len_list[1];
            return [0, substr($content, 4, $xml_len), substr($content, $xml_len + 4)];
        } catch (Exception $e) {
            return [ErrorCode::$IllegalBuffer, null];
        }
    }
1245626
public function encryptWorkbook($encryptionType = 'XOR', $password = '', $keyLength = '')
    {
        //Build JSON to post
        $fieldsArray['EncriptionType'] = $encryptionType;
        $fieldsArray['KeyLength'] = $keyLength;
        $fieldsArray['Password'] = $password;
        $json = json_encode($fieldsArray);
        $strURI = Product::$baseProductUri . '/cells/' . $this->getFileName() . '/encryption';
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'POST', 'json', $json);
        $json_response = json_decode($responseStream);
        if ($json_response->Code == 200)
            return true;
        else
            return false;

    }
1289585
public function getConfig($contentType)
    {
        if (array_key_exists($contentType, $this->searchableTypes)) {
            return $this->searchableTypes[$contentType];
        }

        if ($this->canSearchInvisible() && array_key_exists($contentType, $this->invisibleTypes)) {
            return $this->invisibleTypes[$contentType];
        }

        return false;
    }
225356
public function decrypt(string $encrypted): string {
        $status = openssl_private_decrypt($encrypted, $decrypted, $this);
        if(!$status) {
            throw new RuntimeException('Decrypt failed');
        }
        return $decrypted;
    }