Reputation: 1507
var sha256 = new SHA256Managed();
var hashedValue = sha256.ComputeHash(new byte[] { });
How is .net able to compute hash of empty array?
When bytes are not available, what does it take into consideration while computing hash, or is it just a fixed value?
Upvotes: 2
Views: 671
Reputation: 4014
The message is preprocessed by adding a '1' to the end and then padding it with 0s until the length is congruent to 448 mod 512. After that the length of the message expressed as a 64 bit block is appended to the end.
So starting with an empty message you still apply the preprocessing step to end up with the initial input you perform all the bit shifting and combinatorial logic on.
http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
Upvotes: 4