Decrypt an encrypted value. :param value` (Binary): The encrypted value, a :class:`~bson.binary.Binary` with subtype 6. :return: The decrypted BSON value.
(self, value: Binary)
| 1069 | ) |
| 1070 | |
| 1071 | def decrypt(self, value: Binary) -> Any: |
| 1072 | """Decrypt an encrypted value. |
| 1073 | |
| 1074 | :param value` (Binary): The encrypted value, a |
| 1075 | :class:`~bson.binary.Binary` with subtype 6. |
| 1076 | |
| 1077 | :return: The decrypted BSON value. |
| 1078 | """ |
| 1079 | self._check_closed() |
| 1080 | if not (isinstance(value, Binary) and value.subtype == 6): |
| 1081 | raise TypeError("value to decrypt must be a bson.binary.Binary with subtype 6") |
| 1082 | |
| 1083 | with _wrap_encryption_errors(): |
| 1084 | doc = encode({"v": value}) |
| 1085 | decrypted_doc = self._encryption.decrypt(doc) |
| 1086 | return decode(decrypted_doc, codec_options=self._codec_options)["v"] |
| 1087 | |
| 1088 | def get_key(self, id: Binary) -> Optional[RawBSONDocument]: |
| 1089 | """Get a data key by id. |
nothing calls this directly
no test coverage detected