I wrote a python program to perform the SHA-256 function. It works just fine until I try to hash longer strings.
If I hash (in HEX)
at https://www.pelock.com/products/hash-calculator, I get the result
I do not get that from my own code.
When I perform the second round/iteration, I do not get the correct answer as depicted by that website.
As I understand it, the first iteration should be with the original A-H values, and the first 64 hex chars. Then the next iteration is supposed to have the input of the subsequent hex characters, but no more than 64 of them. I'm also supposed to cycle over the new A-H values from first iteration. Are the new A-H values what I add at the end of the second iteration, or do I still add the original A-H values? What other values do I have to change?
Does the first round have the length-of-the-original-string-that-is-appended of the entire original string (in this case, 384 bits/96 hex characters) or is it only the length of the part of the input we're using (being 64 hex characters/ 256 bits). What is the length that is appended in the second iteration? The original full 384 bits, or merely the length of the part of the input we're working with in the second iteration (being 32 hex characters / 128 bits)?
I do not understand how I'm supposed to re-apply the results of the first iteration to the second iteration to produce the proper result shown above.
Described simply, how are the multiple iterations/rounds of sha256 for long strings, actually applied?