2
$\begingroup$

Do any hash functions exist that provide the same result if the input is reversed?

If this is impossible, why is it impossible?

I am interested in sending packets of constant size around a circuit in a network in both directions, having each node add its value to the hash and then, when the packets meet, compare the hash values.

$\endgroup$

1 Answer 1

2
$\begingroup$

You could take any hash function $H$ and define a new hash function $H'$ as $H'(x) = H(x \Vert x^R)$, where $\Vert$ denotes concatenation and $x^R$ is the reversed version of $x$.

$\endgroup$
3
  • $\begingroup$ If the packets are constant size, how would this work? At the first node, $x_1$ is added to the hash, then $x_2, x_3, ..., x_n$. Going in the opposite direction, we have the hash of $x_n, ..., x_3, x_2, x_1$. But the individual $x_i$s are not stored in the message, only the running hash. $\endgroup$
    – Zaz
    Dec 8, 2023 at 20:02
  • $\begingroup$ @Zaz, I think there is a confusion. Hash functions are defined as a function of the entire input, so they might require having the entire input before they can start any computation, and that's still valid and allowable. You might have some additional requirements not stated in the question. Perhaps you are wishing for a streaming hash function, that must be computed on a very long stream with very low memory usage. If so, please ask a new question that articulates those specific requirements, and elaborate on them. $\endgroup$
    – D.W.
    Dec 8, 2023 at 20:29
  • $\begingroup$ @D.W. Thank you! Is this clear? $\endgroup$
    – Zaz
    Dec 8, 2023 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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