Defined by Zend\Filter\FilterInterface

Encrypts $value with the defined settings

@param  string $value The content to encrypt
@throws Exception\InvalidArgumentException
@return string The encrypted content
550969
public function encrypt($value)
    {
        // compress prior to encryption
        if (!empty($this->compression)) {
            $compress = new Compress($this->compression);
            $value    = $compress($value);
        }

        try {
            $encrypted = $this->blockCipher->encrypt($value);
        } catch (CryptException\InvalidArgumentException $e) {
            throw new Exception\InvalidArgumentException($e->getMessage());
        }
        return $encrypted;
    }
410293
public static function decrypt($value)
        {
            $value      = base64_decode($value);
            // To decrypt the value, we first need to extract the input vector and
            // the encrypted value. The input vector size varies across different
            // encryption ciphers and modes, so we'll get the correct size.

            $iv         = substr($value, 0, static::iv_size());
            $value      = substr($value, static::iv_size());
            // Once we have the input vector and the value, we can give them both
            // to Mcrypt for decryption. The value is sometimes padded with \0,
            // so we will trim all of the padding characters.

            $key        = static::key();
            $value      = mcrypt_decrypt(static::$cipher, $key, $value, static::$mode, $iv);
            return static::unpad($value);
        }
783809
public function encrypt($value)
    {
        $iv = substr(md5(random_bytes(16)), 0, 16);
        $encrypted = openssl_encrypt($value, 'AES-256-CBC', $this->encryptionKey, null, $iv);

        return $this->url_encode($iv.$encrypted);
    }
616902
public function filter($value)
    {
        try {
            $result = $this->normalizeDateTime($value);
        } catch (\Exception $e) {
            // DateTime threw an exception, an invalid date string was provided
            throw new Exception\InvalidArgumentException('Invalid date string provided', $e->getCode(), $e);
        }

        if ($result === false) {
            return $value;
        }

        return $result;
    }
486328
public static function toByteString($value)
    {
        if (self::isStringCastable($value)) {
            return (string)$value;
        } else {
            throw new \InvalidArgumentException(ErrorMessageCreator::create($value, 'ByteString (a string)'));
        }
    }
1118752
public function format($value)
    {
        if (!$this->validate($value))
            throw new \InvalidArgumentException("`{$value}` is not a valid HTTP URI");

        $url = Http::createFromString($value);

        if ($url->getScheme() == '') {
            $url = $url->withScheme('http');
        }

        return (String)$url;
    }
1009225
public function sanitize($value)
    {
        $value = JApplicationHelper::stringURLSafe($value);

        //limit length
        if (mb_strlen($value) > $this->_length) {
            $value = mb_substr($value, 0, $this->_length);
        }

        return $value;
    }
545263
static function ByValue($value)
    {
        $calledClass = get_called_class();
        $allowed = self::AllowedClassValues($calledClass);
        if (!in_array($value, $allowed, true))
            throw new \InvalidArgumentException('Value ' . $value . ' not allowed for enum ' . $calledClass);
        
        return new $calledClass($value);
    }
1055324
public static function serialize($value): string
    {
        $serialized = json_encode(
            self::encode($value, new SplObjectStorage()),
            JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES
        );

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \InvalidArgumentException(json_last_error_msg());
        }

        return $serialized;
    }
956482
protected function filterValue($value): string
    {
        $value = (string) $value;

        if (preg_match("/[^\x21\x23-\x23\x2d-\x3a\x3c-\x5b\x5d-\x7e]/", $value)) {
            throw new InvalidValueException('Invalid cookie header value.');
        }

        return Message\decode($value);
    }
897791
protected function encrypt($value = null, $salt = '')
    {
        return $this->hasher($salt)->encode($this->findValueToSlug($value));
    }
1222027
public static function decode($value)
    {
        if (empty($value)) {
            return null;
        }

        if (!is_string($value)) {
            throw new \InvalidArgumentException(sprintf(
                "Value type '%s' is not a PHP string so it cannot be unserialized.",
                gettype($value)
            ));
        }

        $data = unserialize($value);

        return $data;
    }
1167805
public static function mask($value, $mask)
    {
        if (!Int::is($value) || !Int::is($mask)) {
            throw new \InvalidArgumentException("Both parameters must be integers.");
        }

        return ($value & $mask);
    }
477521
public function encrypt($value)
    {
        $encrypted     = [];
        $encryptedkeys = [];

        if (count($this->keys['public']) == 0) {
            throw new Exception\RuntimeException('Openssl can not encrypt without public keys');
        }

        $keys         = [];
        $fingerprints = [];
        $count        = -1;
        foreach ($this->keys['public'] as $key => $cert) {
            $keys[$key] = openssl_pkey_get_public($cert);
            if ($this->package) {
                $details = openssl_pkey_get_details($keys[$key]);
                if ($details === false) {
                    $details = ['key' => 'ZendFramework'];
                }

                ++$count;
                $fingerprints[$count] = md5($details['key']);
            }
        }

        // compress prior to encryption
        if (!empty($this->compression)) {
            $compress = new Compress($this->compression);
            $value    = $compress($value);
        }

        $crypt  = openssl_seal($value, $encrypted, $encryptedkeys, $keys);
        foreach ($keys as $key) {
            openssl_free_key($key);
        }

        if ($crypt === false) {
            throw new Exception\RuntimeException('Openssl was not able to encrypt your content with the given options');
        }

        $this->keys['envelope'] = $encryptedkeys;

        // Pack data and envelope keys into single string
        if ($this->package) {
            $header = pack('n', count($this->keys['envelope']));
            foreach ($this->keys['envelope'] as $key => $envKey) {
                $header .= pack('H32n', $fingerprints[$key], strlen($envKey)) . $envKey;
            }

            $encrypted = $header . $encrypted;
        }

        return $encrypted;
    }
1031830
public function encrypt($value)
    {
        /**
         * Gets the cipher iv length.
         */
        $iv = random_bytes(openssl_cipher_iv_length($this->cipher));

        /**
         * Encrypts the given value.
         */
        $value = \openssl_encrypt($value, $this->cipher, $this->key, 0, $iv);

        $hash_mac = $this->mac($iv = base64_encode($iv), $value);

        if (!$value) {
            throw new Exception('Unable to encrypt given value');
        }

        $encrypted = json_encode(compact('iv', 'value', 'hash_mac'));

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new Exception('Unable to encrypt given value.');
        }

        return base64_encode($encrypted);
    }
139565
public function setValue($value)
    {
        if (null !== $value) {
            if (!$this->validateValue($value)) {
                throw new \InvalidArgumentException(\sprintf(
                    'Binding invalid value (type "%s") into filter "%s" (%s)',
                    \is_object($value) ? \get_class($value) : \gettype($value),
                    $this->name,
                    \get_class($this)
                ));
            }

            $this->value = $value;
            $this->updateBound();
        }

        return $this;
    }
112855
public function serialize($value) : string
    {
        if (!$value instanceof Metadata) {
            throw InvalidValueException::valueDoesNotMatchType($this, $value);
        }

        return (string) $value->id();
    }