我想序列化/反序列化md5上下文。但我不知道如何用Python做到这一点。 我想要做的伪代码。序列化MD5计算状态并稍后恢复?
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()
这里有C++库。有Python吗?为什么md5库不支持它?有没有安全问题?谢谢。
编辑: 我想这样做,因为例如,HTTP服务器想要接受不同HTTP请求中的流数据。在请求之间以某种方式序列化md5上下文会很方便。
你为什么要那么做? –
http://stackoverflow.com/questions/5865824/hash-algorithm-for-dynamic-growing-streaming-data – Kevin
谢谢。 pypy库说不使用它因为它没有测试=(为什么官方的python md5没有实现这个寿命? – Yey