序列化MD5计算状态并稍后恢复? [英] Serialize MD5 computation-state and resume later?
问题描述
我想序列化/反序列化md5上下文。但我不知道如何用Python做到这一点。
我想要做的伪代码。
import md5
#开始哈希生成
m = md5.new()
m.update(Content)
#序列化m
serialized_m =序列化(m)
#在另一个函数/机器,反序列化m
#并继续哈希生成
m2 =反序列化(serialized_m)
m2.update(更多内容)
m2.digest()
这里有C ++库。有Python吗?为什么md5库不支持它?有没有安全问题?感谢。
编辑:
我想这样做,因为例如,HTTP服务器想要在不同的HTTP请求中接受流数据。在请求之间以某种方式序列化md5上下文会很方便。
http://bugs.python。 org / issue16059
I want to serialize/deserialize md5 context. But I don't know how to do it in Python. Pseudocode of what I want to do.
import md5
# Start hash generation
m = md5.new()
m.update("Content")
# Serialize m
serialized_m = serialize(m)
# In another function/machine, deserialize m
# and continue hash generation
m2 = deserialize(serialized_m)
m2.update("More content")
m2.digest()
There are C++ libraries for this. Is there one for Python? Why doesn't the md5 library support it? Are there security concerns? Thanks.
Edited: I want to do this because for example, an HTTP server wants to accept streaming data in different HTTP requests. It would be convenient to serialize md5 context somehow between requests.
I asked Mr Guido V Rossum. He replied that "I don't think there's a way. However it might make a decent feature request. You could submit one to bugs.python.org." So I did.
http://bugs.python.org/issue16059
这篇关于序列化MD5计算状态并稍后恢复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!