0

I need to find the SHA256 hash of s string like this: "part1-part2". I know the SHA256 hash of part1 and I know what part2 represents, but I don't know what is the contents of part1.

Is there any chance I can compute the hash of the whole string using these two?

Daniel
  • 111
  • 3

1 Answers1

3

You may be able to compute a SHA256 of part1-part2, if you already knew SHA256(part1), and the value for part2. This relies on a vulnerability in the underlying method of hash construction SHA256 uses (https://en.wikipedia.org/wiki/Length_extension_attack).

EDIT: To clarify the algorithm SHA256 will pad any input to a multiple of some given size.

Soo really you could think of it as SHA256(part1||padding), where 'padding' means x00 repeated till size(part1||padding) mod 512 = 0 (since SHA256 has a block size of 512 https://en.wikipedia.org/wiki/Secure_Hash_Algorithm). This becomes a problem if any padding needs to be added to part1.

Daisetsu
  • 5,110
  • 1
  • 14
  • 24