1

For example I want to send text document with content:

---start of hello.txt---
Hello world!

SHA-256 hash of this document is: e5cefc21ce1131cc0e8759f5e3b46c016319883c6f9b0d714502f3cf7226864f
---end of hello.txt---
  • 1
    So you are asking if you could create a document with known text where hash_as_hex(text + hexdigest) = hexdigest ? What is the use case for this or is it just curiosity? – Steffen Ullrich Mar 1 '17 at 10:38
  • Are you trying to hash the document and then putting that same hash in the same document? It's like 'hashception'? – Lester T. Mar 1 '17 at 11:00
  • 1
    There is no standard way to do this for SHAs. Also see stackoverflow.com/questions/4432669/… – Jedi Mar 1 '17 at 11:01
6

No. It is a problem akin to that of the self-enumerating pangram, but since the hash function is not reversible, the only way of doing this is by brute force. Given the size of the key space, this is unfeasible.

| improve this answer | |
0

I guess you could potentially include a hash of the other content in the file in the file - e.g.

---START CONTENT---
some content
----END CONTENT---
Hash of CONTENT: sha256:aaaaf

It isn't clear what that achieves, though, because anyone able to intercept the message can replace both the content and hash - something using e.g. HMAC would prevent.

| improve this answer | |

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.