diff --git a/pgpy/pgp.py b/pgpy/pgp.py index ab05f4a9..423a87a8 100644 --- a/pgpy/pgp.py +++ b/pgpy/pgp.py @@ -2822,7 +2822,8 @@ def encrypt(self, message: PGPMessage, sessionkey: Optional[bytes] = None, user: Optional[str] = None, - cipher: Optional[SymmetricKeyAlgorithm] = None) -> PGPMessage: + cipher: Optional[SymmetricKeyAlgorithm] = None, + max_featureset: Optional[Features] = None) -> PGPMessage: """Encrypt a PGPMessage using this key. :param message: The message to encrypt. @@ -2871,6 +2872,9 @@ def encrypt(self, if compprefs is None: compprefs = [] + if max_featureset is not None: + features &= max_featureset + pref_cipher = next((c for c in cipherprefs if c.is_supported), SymmetricKeyAlgorithm.TripleDES) cipher_algo = cipher if cipher is not None else pref_cipher