I have two byte arrays lets say A and B. And I computed MD5 Hash AH and BH for them respectively. Now if I Combine these arrays A and B to AB, and compute MD5 hash as ABH what whould be the way to combine AH and BH to equate ABH?
-
a) I don't think that's possible. (But I have no special knowledge of this area.) b) According to this http://en.wikipedia.org/wiki/MD5, MD5 is considered to be "cryptographically broken and unsuitable for further use". – RenniePet Sep 14 '14 at 12:34
-
2If you find an easy way to do this you will be famous. – Steve Ruble Sep 14 '14 at 12:34
-
I don't think hashing is going to provide you with what you want. Could you update the question with some details about *why* you need to be able to do something like this? Perhaps we can provide a different solution to your problem. – Steve Ruble Sep 14 '14 at 13:18
-
Im in a situation where i need to upload a file of which I need to maintain hash to make sure that the file intactness is verifyable. later on i need to add a chuck of bytes to the uploaded file making it as a version 2. depending on the requested user authorization i need to give them initial version or later versions. – Sreekanth Vaddepati Sep 14 '14 at 13:25
-
Take a look at the rsync algorithm, it's very instructive. – Lucas Trzesniewski Sep 14 '14 at 13:48
2 Answers
Based on your comments that you don't need a cryptographic hash, but just some kind of "fingerprint" to give a certain degree of hash = data assurance, then here's one possibility:
The simplest hash of all is to just XOR (exclusive-or) the data against itself. So for an 8-byte hash, you just walk over the data and XOR every 8 bytes together, producing an 8-byte hash. This provides a very high degree of certainty, unless the "bad guys" know how you do the hashing, then it is easy to fake.
If you concatenate two data arrays, A and B, then as long as A is a multiple of 8 in length, or if it's acceptable to place zeros padding between A and B so A + padding is a multiple of 8, then the combined hash will be (hash of A) XOR (hash of B). (At least, that's what I learned 50 years ago, if I remember right.)
Edit:
Just found this: Why is XOR the default way to combine hashes?
It's possible that cryptography experts may have some ability to use partial MD5 hashes of a value to get some information about the MD5 hash for the complete value, but for practical purposes the only way to get the MD5 hash of a value is to compute the MD5 hash from that value.

- 3,875
- 21
- 27
-
Is there any way possible by any other hashing technique to achieve this? – Sreekanth Vaddepati Sep 14 '14 at 13:02
-
@SreekanthVaddepati: Do you mean a cryptographic hashing, or any old hashing, like what is used to provide an index to a hash table? – RenniePet Sep 14 '14 at 13:11
-