My question is whether it is possible to use "another" algorithm than the sha256 to hash data but end up with the identical sha256 hash (obviously without using the sha256 algorithm)?
2 Answers
Due to the pigeonhole principle, any random function will eventually produce collisions with any other random function. After all, there are far more possible inputs than there are possible outputs (for most traditional cryptographic hashes). However, there isn't any way to create an algorithm that always produces the same hash as SHA-256 for the same input without that algorithm being SHA-256.
Given two random functions $f$ and $g$ (any good cryptographic hash will adequately approximate a random function for all intents and purposes), $\exists{m}:f(m) = g(m)$. This means that there will exist some message $m$ that produces the same hash with both functions. It is also true that there can exist two different messages which, when hashed with different functions, produce the same result (i.e. $\exists m,n: f(m) = g(n)$, which is called a claw). However, if $\forall{m}:f(m) = g(m)$ (i.e. every message results in the same hash when hashed with the other function), then the functions are identical. There is no situation where that can be true but $f$ and $g$ are not the same.
- 15,626
- 2
- 49
- 103
In my opinion, it depends on what you mean by “another” (ie. “different”) algorithm.
Here are two algorithms. Each one takes a number as input, and produces a new number as output:
(1)
- Take input number
- Add 25
(2)
- Take input number
- Add 30
- Subtract 5
Are those the same algorithm?
From one viewpoint, clearly NO – one of them has only two steps, the other has three.
But from another viewpoint, YES – given the same input, they both produce exactly the same output.
So like many questions, it really depends on what you actually mean by the terms in the question. For your question, it depends on what you actually mean by the term “another algorithm”.
- 106
- 1
- 6