Let's say I have a file A, which is any normal file (pdf, jpeg, mp3 etc.)
Now I get the binary dump of file, say another file B{A}.
And the hexdump of file say, file H{A}.
Now I hash all the three files with any 256 bit HASH (SHA256, BLAKE256 etc.)
I want to know that :
1. What is the possiblity of hash collision in this case (Considering if somehow I find a collison in case of file A, I still can generate the hex and binary dump of that file to see if hashes of B{A} and H{A} matches or not).
2. Will it still be 1/256* 256* 256? Or
3. Will there be 0 collision ? (Considering collision between exactly same size of files)


Approximating a Hash function $h$ as a function that maps each word in $\{0,1\}^*$ to a word in $\{0,1\}^{256}$ chosen uniformly at random, you can find the probability that at least one of the events:

  • $h(A)=h(B\{A\})$,
  • $h(A)=h(H\{A\})$,
  • $h(B\{A\})=h(H\{A\})$

is true by looking at the complementary probability. The probability that $h(A)$, $h(B\{A\})$, and $h(H\{A\})$ are all distinct is $1 \cdot (1 - \frac{1}{2^{256}}) \cdot (1 - \frac{2}{2^{256}})$. Then, the probability of having at least one collision is then: $$ 1- \left(1 - \frac{1}{2^{256}}\right) \cdot \left(1 - \frac{2}{2^{256}}\right) \approx 2.6 \cdot 10^{-77}. $$

  • $\begingroup$ Thank you for explanation. $\endgroup$
    – Akash
    Sep 6 '21 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.