diff --git a/GnuPG/__init__.py b/GnuPG/__init__.py index 7a8dd47..16ef67a 100644 --- a/GnuPG/__init__.py +++ b/GnuPG/__init__.py @@ -197,8 +197,11 @@ class GPGDecryptor: def decrypt(self): """Decrypt the message.""" p = subprocess.Popen(self._command(), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - decdata = p.communicate(input=self._message)[0] - return (decdata, p.returncode) + try: + decrypted = pysequoia.decrypt(bytes = self._message) + return (decrypted.bytes.decode("utf8"), 0) + except: + return ("", 1) def _command(self): return _build_command(self._keyhome, "--trust-model", "always", "--batch", "--yes", "--no-secmem-warning", "-a", "-d")