【发布时间】:2019-10-19 13:02:50
【问题描述】:
我正在尝试制作一个简单的工具来解密 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.
【问题讨论】: