openssl_pkcs7_encrypt
Function • Params changed in PHP 8.1
Encrypt an S/MIME message.
openssl_pkcs7_encrypt Function synopsis
openssl_pkcs7_encrypt(
string $input_filename,
string $output_filename,
$certificate,
?array $headers,
int $flags = 0,
int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
): bool
Parameters
$input_filename
Typestring
$output_filename
Typestring
$certificate
Either a lone X.509 certificate, or an array of X.509 certificates.
$headers
Type?array
$headers is an array of headers that
will be prepended to the data after it has been encrypted.
$flags
OptionalTypeintDefault value0
$flags can be used to specify options that affect
the encoding process - see PKCS7
constants.
$flags accepts one or a bitmask of the following constant values:
PKCS7_TEXTPKCS7_BINARYPKCS7_NOINTERNPKCS7_NOVERIFYPKCS7_NOCHAINPKCS7_NOCERTSPKCS7_NOATTRPKCS7_DETACHEDPKCS7_NOSIGS
$cipher_algo
OptionalTypeintDefault valueOPENSSL_CIPHER_AES_128_CBC
One of cipher constants.
Return value
Typebool
Returns true on success, false on failure
Changes to the openssl_pkcs7_encrypt Function
PHP 8.1
- Parameter default value changed for position #6 (
$cipher_algo):OPENSSL_CIPHER_RC2_40toOPENSSL_CIPHER_AES_128_CBC
openssl_pkcs7_encrypt(
string $input_filename,
string $output_filename,
$certificate,
?array $headers,
int $flags = 0,
- int $cipher_algo = OPENSSL_CIPHER_RC2_40
+ int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC
): bool PHP 8.0
- Return type added:
bool - Parameter name of parameter #1 changed:
$infileto$input_filename - Parameter type added for parameter #1 (
$input_filename):string - Parameter name of parameter #2 changed:
$outfileto$output_filename - Parameter type added for parameter #2 (
$output_filename):string - Parameter name of parameter #3 changed:
$recipcertsto$certificate - Parameter type added for parameter #4 (
$headers):?array - Parameter type added for parameter #5 (
$flags):int - Parameter default value added for position #5 (
$flags):0 - Parameter name of parameter #6 changed:
$cipherto$cipher_algo - Parameter type added for parameter #6 (
$cipher_algo):int - Parameter default value added for position #6 (
$cipher_algo):OPENSSL_CIPHER_RC2_40
openssl_pkcs7_encrypt(
- $infile,
+ string $input_filename,
- $outfile,
+ string $output_filename,
- $recipcerts,
+ $certificate,
- $headers,
+ ?array $headers,
- $flags,
+ int $flags = 0,
- $cipher
+ int $cipher_algo = OPENSSL_CIPHER_RC2_40
- )
+ ): bool openssl_pkcs7_encrypt Function Availability
openssl_pkcs7_encrypt Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |