我正在尝试制作一个脚本,用于发送PGP邮件进行测试
我使用GnuPG就是为了这个目的,gpg.sign()和gpg.encrypt()函数似乎什么也不返回/返回空字符串,甚至没有返回错误
find_key函数似乎也能正常工作,所以我不太明白为什么gpg.encrypt()不会产生任何结果。有人能帮我吗
def PGP_encrypt():
message = MIMEText("Test PGP Encrypt")
message["From"] = "sender@example.com" # Shown Sender
message["To"] = config.get("recipient")
message['Subject'] = "Testing Suite - Automated Message"
message['Date'] = datetime.datetime.now().strftime('%d/%m/%Y %H:%M')
print(find_key(config.get("recipient")))
print(str(message))
PGP_encrypt_message = gpg.encrypt(data=str(message), recipients=find_key(config.get("recipient")), sign=False)
print(str(PGP_encrypt_message))
我使用PythonGnupg库运行Python3.8.5。find_键功能以及消息本身似乎工作正常
尝试运行代码时,结果是:
27RANDOMKEY96F81
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: sender@example.com
To: recipient@example.com
Subject: Testing Suite - Automated Message
Date: 17/11/2020 17:04
Test PGP Encrypt
消息和密钥都很好,但“加密”对象似乎是空的。同样的行为似乎也发生在符号函数中。 有人知道我在这里遗漏了什么吗
目前没有回答
相关问题 更多 >
编程相关推荐