For any bitcoin block we combine various Header fields to create a string which is an input to a 2 pass SHA algorithm. The resultant hash must match with the Hash in the Block header for the Block to be valid.
To test this logic as well as SHA algorithm, I used the header of Block number 695877 (https://blockchain.info/rawblock/695877?format=json) to create the Input string 04008020546c359986812644420e453113e209afeaaeeb316f3a07000000000000000000b8fa13b3fca087c1456daac626ab9b8a47eae821a326f17e0ffffc15433df709b0f718610b1812175a5c9544.
Now when I apply the 2 pass SHA algorithm the resultant hash matches the hash in the Block (ignoring the Endian part for the time being).
Calculated Hash: 629ef98d63e12f6b01476419a5a71efa8814dea40aec09000000000000000000
Block hash: 00000000000000000009ec0aa4de1488fa1ea7a5196447016b2fe1638df99e62
But when I pad the header manually before passing it to 2 pass SHA algorithm as follows: 04008020546c359986812644420e453113e209afeaaeeb316f3a07000000000000000000b8fa13b3fca087c1456daac626ab9b8a47eae821a326f17e0ffffc15433df709b0f718610b1812175a5c9544800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000280 This is resulting in an incorrect hash.
I am failing to see what is wrong in the padding. Can someone please point it out?