开发者

If I know the hashes of two parts of some data, can I calculate the hash of the full data from those hashes?

If I kn开发者_开发知识库ow the hashes of two (or more) parts of some data, can I calculate the hash of the full data from those hashes?

Which hash types can this be done for? SHA1, SHA256, MD5? (Security of hashes is not important for my use case.)

i.e.

data0 = '0123'
data1 = '45678'
all_data = data0 + data1
hash0 = hash(data0)
hash1 = hash(data1)

Does fn exist such that

hash(all_data) == fn(hash0, hash1)

Does fn exist for MD5, SHA1 or SHA256?

Thanks,

Chris.


Short answer. No.

Hashes are completely different for minimal deviations and untill you can't calculate them back this won't work. Even if you can calculate them back, the result will be a list of possibilities you can choose from. So there is nothing deterministic.


Hashing through data0 puts the system in some intermediate state. Your hash(data1) was calculated from a clean state. You cannot fix hash1 to make up for that missing intermediate state (for a good hash function).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜