MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / decrypt

Method decrypt

pymongo/synchronous/encryption.py:1071–1086  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 5

_check_closedMethod · 0.95
encodeFunction · 0.90
decodeFunction · 0.90
_wrap_encryption_errorsFunction · 0.70
decryptMethod · 0.45

Tested by

no test coverage detected