我正在尝试制作一个简单的工具来解密GPG信息,但是我一直在解密消息时遇到错误,我不知道问题出在哪里。
以下是代码:
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)
这里是错误信息:
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.