I am trying to make a simple tool that decrypts a GPG message, but I keep getting an error decrypting the message, I dont know where the issue is coming from.
Here is the code:
import gnupg
import os
message = '''-----BEGIN PGP MESSAGE-----
Version: GnuPG v2
jA0ECQMCVady3RUyJw3X0kcBF+zdkfZOMhISoYBRwR3uk3vNv+TEg+rJnp4/yYIS
pEoI2S82cDiCNBIVAYWB8WKPtH2R2YSussKhpSJ4mFgqyOA01uwroA==
=KvJQ
-----END PGP MESSAGE-----
'''
passphrase = 'topsecret'
gpg = gnupg.GPG(os.popen("which gpg").read().strip())
decrypted_data = str(gnupg.decrypt(message, passphrase=passphrase))
print(decrypted_data)
Here is the error:
PermissionError: [Errno 13] Permission denied: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 29, in <module>
gpg = gnupg.GPG(os.popen("which gpg").read().strip())
File "/Users/***/PycharmProjects/untitled8/venv/lib/python3.6/site-packages/gnupg.py", line 849, in __init__
raise OSError(msg)
OSError: Unable to run gpg () - it may not be available.