php8.5
Home/ Manual/ driver / clientencryption/ MongoDB\Driver\ClientEncryption::encrypt

MongoDB\Driver\ClientEncryption::encrypt

PHP function Edit on GitHub ✎

(mongodb >=1.7.0)

Encrypt a value

Description

MongoDB\Driver\ClientEncryption::encrypt(mixed $value, array|null $options = null): MongoDB\BSON\Binary

Encrypts the value.

Parameters

value

The value to be encrypted. Any value that can be inserted into MongoDB can be encrypted using this method.

Return Values

Returns the encrypted value as MongoDB\BSON\Binary object with subtype 6.

Errors/Exceptions

  • Throws MongoDB\Driver\Exception\EncryptionException if an error occurs while encrypting the value

Changelog

VersionDescription
PECL mongodb 1.20.0Added the "trimFactor" range option. The "sparsity" range option is now optional.
PECL mongodb 1.16.0Added the "rangeOpts" option.
PECL mongodb 1.14.0Added the "contentionFactor" and "queryType" options.

See Also

Source: reference/mongodb/mongodb/driver/clientencryption/encrypt.xml · from the official PHP manual (php/doc-en)