Something like:

$$ h = Hash(\texttt{"Some String"} \mathbin\| h)$$

  • 1
    $\begingroup$ I think that will break the pre-image property. $\endgroup$
    – kelalaka
    Oct 3, 2022 at 19:49
  • $\begingroup$ If the hash function is random-looking, then no. It's hard to reduce this to any of the usual security notions, as far as I can tell, and I think you can construct silly counterexamples. Note that you can find solutions to $h = Hash(blah || f(h))$ for some interesting functions $f$, such as in your favourite signature scheme. $\endgroup$
    – K.G.
    Oct 4, 2022 at 6:48
  • $\begingroup$ Here's a GIF that displays its own MD5 hash. Note that this does not imply that the answer to the question is affirmative. $\endgroup$
    – yyyyyyy
    Nov 5, 2022 at 3:59

2 Answers 2


Yes, it is possible. You can create many such functions. For instance, define hash function as last 16 symbols or bytes of the original message:

$h(x) = substring(x, length(x)-16, length(x))$

As @kelalaka noticed, it is trivial to find preimages for any hash that fits your requirement. That's why such functions are useless for typical cryptographic purposes.

  • 1
    $\begingroup$ This answer is only correct for a definition of the word “hash” that does not include any security properties. This is a site about cryptography, so the word “hash” means a cryptographic hash function (or in some contexts, but not here, a password hashing function), or at least (since we can't even prove that such a function exists) a function that is or was widely believed to be one. Truncating the input is unambiguously not a cryptographic hash function. $\endgroup$ Oct 6, 2022 at 16:32
  • $\begingroup$ @Gilles'SO-stopbeingevil': No. According to your logic, any mention of PRNG should be treated as CSPRNG. But that is not true. We treat PRNG namely as PRNG. And when CSPRNG is impotant, is is mentioned explicitly as such. That's why as long as there is no requirements about cryptographic properties of hash it means hash function in the generic meaning. Furthermore, I pointed out that such function is useless for cryptographic purposes. I find your comment not helpful. $\endgroup$
    – mentallurg
    Oct 6, 2022 at 18:19

If you have a cryptographic hash that is not 'broken', yet, essentially the only way to create this special string is through brute force.

Yes, in theory if you apply enough brute force computations, you can find such strings.


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.