MD5/SHA“更新”财产?
允许您“更新”它们的 MD5/SHA 属性是什么?例如,如果您有“test”的哈希值,则可以添加“case”来获取“testcase”的哈希值。我想稍微了解一下这个房产,但我的搜索没有发现任何结果......
What is the MD5/SHA property that allows you to "update" them? For example, if you have the hash for "test" you can add "case" to get the hash for "testcase". I would like to read up on this property a bit but my searches turn up nothing...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只是它们实际上是增量计算的——您通过对数据的前 n 个字节进行操作来计算它们(MD5 的情况下为 128,请参阅 http://en.wikipedia.org/wiki/MD5#Algorithm),然后是接下来的 n 个字节的数据,等等。
It is merely that they are actually calculated incrementally -- you calculate them by operating on the first n bytes of data, (128 in the case of MD5, see http://en.wikipedia.org/wiki/MD5#Algorithm), then on the next n bytes of data, etc.
编辑:这在理论上是不可能的,因为我在下面提到了 1 位填充。实际上,
md5("case", Seed=md5("test")) == md5("test" + <1-bit> + "case")
。无法使用md5("test")
增量计算md5("test" + "case")
。如果您连接 512 位块,这在理论上是可能的。它不适用于将“case”附加到“test”,因为状态机的第一次运行受到用于将“case”转换为 512 位块的填充的污染。此外,填充不是不只是一堆零。消息总是先用 1 位填充,以便“case”和“case\0”产生不同的哈希值。因此,您不能依赖“case”具有相同的哈希值(带或不带填充)。
EDIT: This isn't even theoretically possible, due to the 1-bit padding I mention below. In effect,
md5("case", seed=md5("test")) == md5("test" + <1-bit> + "case")
. There is no way to usemd5("test")
to incrementally computemd5("test" + "case")
.This is theoretically possible if you concatenate 512-bit chunks. It won't work for appending "case" to "test", because the first run of the state machine is polluted by the padding used to turn "case" into a 512-bit chunk.Additionally, the padding isn't just a bunch of zeros. The message is always first padded with a 1 bit, so that "case" and "case\0" produce different hashes. Thus you can't rely on "case" having the same hash with or without padding.
MD5 算法具有以下步骤:
为了支持您想要分阶段散列某些内容(例如大文件)的情况,可以按如下方式重构。
初始化:
更新:
摘要:
我实际上已经在 VBA 中实现了这种方法 - 它似乎工作得很好。关于我应该在哪里上传代码有什么建议吗?
The MD5 algorithm has the following steps:
To support situations where you want to hash something in stages (e.g. large files), this can be refactored as follows.
Initialise:
Update:
Digest:
I've actually implemented this approach in VBA - it seems to work fine. Any suggestions for where I should upload the code?