openssl_cms_encrypt

FunctionParams changed in PHP 8.5

Encrypt a CMS message.

PHP 5
PHP 7
PHP 8.0
Added
PHP 8.1
Improved
PHP 8.2
PHP 8.3
PHP 8.4
PHP 8.5
Improved
PHP 8.6

openssl_cms_encrypt Function synopsis

openssl_cms_encrypt(
    string $input_filename,
    string $output_filename,
    $certificate,
    ?array $headers,
    int $flags = 0,
    int $encoding = OPENSSL_ENCODING_SMIME,
    string|int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
  ): bool

Parameters

$input_filename

Typestring

The file to be encrypted.

$output_filename

Typestring

The output file.

$certificate

Recipients to encrypt to.

$headers

Type?array

Headers to include when S/MIME is used.

$flags

OptionalTypeintDefault value0

Flags to be passed to CMS_sign.

$encoding

OptionalTypeintDefault valueOPENSSL_ENCODING_SMIME

An encoding to output. One of OPENSSL_ENCODING_SMIME, OPENSSL_ENCODING_DER or OPENSSL_ENCODING_PEM.

$cipher_algo

OptionalTypestring|intDefault valueOPENSSL_CIPHER_AES_128_CBC

A cypher to use.

Return value

Typebool

Returns true on success, false on failure

Changes to the openssl_cms_encrypt Function

PHP 8.5

  • Parameter type changed for parameter #7 ($cipher_algo): int to string|int
  openssl_cms_encrypt(
      string $input_filename,
      string $output_filename,
      $certificate,
      ?array $headers,
      int $flags = 0,
      int $encoding = OPENSSL_ENCODING_SMIME,
-     int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
+     string|int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
    ): bool

PHP 8.1

  • Parameter default value changed for position #7 ($cipher_algo): OPENSSL_CIPHER_RC2_40 to OPENSSL_CIPHER_AES_128_CBC
  openssl_cms_encrypt(
      string $input_filename,
      string $output_filename,
      $certificate,
      ?array $headers,
      int $flags = 0,
      int $encoding = OPENSSL_ENCODING_SMIME,
-     int $cipher_algo = OPENSSL_CIPHER_RC2_40
+     int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
    ): bool

PHP 8.0

  • Function added

openssl_cms_encrypt Function Availability

PHP VersionAvailability
PHP 8.6Future Release Yes
PHP 8.5Upcoming Release Yes
PHP 8.4Supported (Latest) Yes
PHP 8.3Supported Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Security-Fixes Only Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported No
PHP 7.3Unsupported No
PHP 7.2Unsupported No
PHP 7.1Unsupported No
PHP 7.0Unsupported No
PHP 5.6Unsupported No
PHP 5.5Unsupported No
PHP 5.4Unsupported No
PHP 5.3Unsupported No