src/AESGCM.php
public static function encrypt($K, $IV, $P = null, $A = null, $tag_length = 128)
    {
        Assertion::string($K, 'The key encryption key must be a binary string.');
        $key_length = mb_strlen($K, '8bit') * 8;
        Assertion::inArray($key_length, [128, 192, 256], 'Bad key encryption key length.');
        Assertion::string($IV, 'The Initialization Vector must be a binary string.');
        Assertion::nullOrString($P, 'The data to encrypt must be null or a binary string.');
        Assertion::nullOrString($A, 'The Additional Authentication Data must be null or a binary string.');
        Assertion::integer($tag_length, 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');
        Assertion::inArray($tag_length, [128, 120, 112, 104, 96], 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');

        if (version_compare(PHP_VERSION, '7.1.0RC5') >= 0 && null !== $P) {
            return self::encryptWithPHP71($K, $key_length, $IV, $P, $A, $tag_length);
        } elseif (class_exists('\Crypto\Cipher')) {
            return self::encryptWithCryptoExtension($K, $key_length, $IV, $P, $A, $tag_length);
        }

        return self::encryptWithPHP($K, $key_length, $IV, $P, $A, $tag_length);
    }
public static function encrypt($K, $IV, $P = null, $A = null, $tag_length = 128)
    {
        Assertion::string($K, 'The key encryption key must be a binary string.');
        $key_length = mb_strlen($K, '8bit') * 8;
        Assertion::inArray($key_length, [128, 192, 256], 'Bad key encryption key length.');
        Assertion::string($IV, 'The Initialization Vector must be a binary string.');
        Assertion::nullOrString($P, 'The data to encrypt must be null or a binary string.');
        Assertion::nullOrString($A, 'The Additional Authentication Data must be null or a binary string.');
        Assertion::integer($tag_length, 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');
        Assertion::inArray($tag_length, [128, 120, 112, 104, 96], 'Invalid tag length. Supported values are: 128, 120, 112, 104 and 96.');

        if (version_compare(PHP_VERSION, '7.1.0RC5') >= 0 && null !== $P) {
            return self::encryptWithPHP71($K, $key_length, $IV, $P, $A, $tag_length);
        } elseif (class_exists('\Crypto\Cipher')) {
            return self::encryptWithCryptoExtension($K, $key_length, $IV, $P, $A, $tag_length);
        }

        return self::encryptWithPHP($K, $key_length, $IV, $P, $A, $tag_length);
    }
@param string      $K          Key encryption key
@param string      $IV         Initialization vector
@param null|string $P          Data to encrypt (null for authentication)
@param null|string $A          Additional Authentication Data
@param int         $tag_length Tag length

@return array