openssl_cms_encrypt
PHP function
Edit on GitHub ✎
(PHP 8)
Encrypt a CMS message
Description
openssl_cms_encrypt(string $input_filename, string $output_filename, OpenSSLCertificate|array|string $certificate, array|null $headers, int $flags = 0, int $encoding = OPENSSL_ENCODING_SMIME, string|int $cipher_algo = OPENSSL_CIPHER_AES_128_CBC): bool
This function encrypts content to one or more recipients, based on the certificates that are passed to it.
Parameters
input_filenameThe file to be encrypted.
output_filenameThe output file.
certificateRecipients to encrypt to.
headersHeaders to include when S/MIME is used.
flagsFlags to be passed to CMS_sign.
encodingAn encoding to output. One of
OPENSSL_ENCODING_SMIME,OPENSSL_ENCODING_DERorOPENSSL_ENCODING_PEM.cipher_algoA cipher to use.
Return Values
Success
Changelog
| Version | Description |
|---|---|
| 8.5.0 | cipher_algo is now of type int or string. Previously, it was of type int. |
| 8.1.0 | The default cipher algorithm (cipher_algo) is now AES-128-CBC (OPENSSL_CIPHER_AES_128_CBC). Previously, PKCS7/CMS was used (OPENSSL_CIPHER_RC2_40). |