dkim身体在python中
我认为这应该很容易,但是我只是无法获得多个Mime电子邮件的身体上的hashsum。我的代码不起作用,因此我只提供了一个简单的示例(我正在提供一个带有完整电子邮件,标题和所有内容的文件):
#!/usr/bin/env python3
import email
import sys
from base64 import b64encode, b64decode
import hashlib
mail = email.message_from_bytes(open(sys.argv[1], "rb").read())
body = str(mail.get_payload())
canonicalized_body = body.strip().encode() + b"\r\n"
print("SHA256\t:", b64encode(hashlib.sha256(canonicalized_body).digest()))
print("SHA1\t:", b64encode(hashlib.sha1(canonicalized_body).digest()))
有人熟悉此吗?戈伊有什么想法吗?
I'm thinking this should be easy, but I just can't get the body hashsum right for multipart MIME e-mails. My code doesn't work so I just included a simple example of what I'm doing (I'm supplying a file with a full e-mail, headers and all):
#!/usr/bin/env python3
import email
import sys
from base64 import b64encode, b64decode
import hashlib
mail = email.message_from_bytes(open(sys.argv[1], "rb").read())
body = str(mail.get_payload())
canonicalized_body = body.strip().encode() + b"\r\n"
print("SHA256\t:", b64encode(hashlib.sha256(canonicalized_body).digest()))
print("SHA1\t:", b64encode(hashlib.sha1(canonicalized_body).digest()))
Anyone familiar with this? Goy any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论