# Can I compute “SHA256(secret||data)” when having “SHA256(secret)” and “data”?

I need to find the SHA256 hash of s string like this: part1-part2. I know the SHA256(part1), length of part1 and I know part2, 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 only these three parts of information?

• You can compute $\operatorname{SHA256}(\mathit{secret}\Vert\mathit{padding}\Vert\mathit{data})$ using a length extension attack, but computing $\operatorname{SHA256}(\mathit{secret}\Vert\mathit{data})$ for freely chosen $\mathit{data}$ without the $\mathit{padding}$ in between is assumed to be hard (i.e. practically impossible, unless SHA256 turns out to be severely broken). HashPump is a tool to perform length extensions. – yyyyyyy Apr 23 '16 at 9:07
• I understand. This attack is not suitable for what I am looking for, as it doesn't give me the exact SHA256(secret||data). Thank you for explaining :) – Daniel Apr 23 '16 at 17:12

$$\operatorname{SHA256}(\mathit{secret}\Vert\mathit{padding}\Vert\mathit{data})$$
But computing $\operatorname{SHA256}(\mathit{secret}\Vert\mathit{data})$ for freely chosen $\mathit{data}$ without the $\mathit{padding}$ in between is assumed to be “hard”; meaning that you’ll end up having to brute-force your way towards a result.