我试图像这样初始化gpg:
BIN = C:/cygwin64/bin/gpg.exe
HOME = C:/cygwin64/home/Administrator/.gnupg
gpg = gnupg.GPG(binary=BIN, homedir=HOME)
我的钥匙圈位于C:/cygwin64/home/Administrator/.gnupg
,但只要我使用list_keys
命令:
public_keys = gpg.list_keys()
private_keys = gpg.list_keys(True)
print ('public keys:')
print(public_keys)
print ('private keys:')
print(private_keys)
它输出空的空数组。
所以我尝试用这种方式指定环的特定路径:
gpg = gnupg.GPG(binary=BIN, homedir=HOME, ignore_homedir_permissions=True,
keyring='C:/cygwin64/home/Administrator/.gnupg/secring.gpg',
secring='C:/cygwin64/home/Administrator/.gnupg/pubring.gpg')
同样的错误。
以下是我尝试解密文件时遇到的错误:
stderr: gpg: WARNING: unsafe permissions on homedir `C:/cygwin64/home/Administrator/.gnupg'
gpg: invalid key resource URL `C:/cygwin64/home/Administrator/.gnupg/pubring.gpg'
gpg: keyblock resource `(null)': general error
gpg: invalid key resource URL `C:/cygwin64/home/Administrator/.gnupg/secring.gpg'
gpg: keyblock resource `(null)': general error
gpg: no valid OpenPGP data found.
[GNUPG:] NODATA 1
[GNUPG:] NODATA 2
gpg: decrypt_message failed: eof
我错过了什么?