How does a hash digest update function work?

170 Views Asked by At

When creating a hash digest, in most libraries you have the option to update the input an arbitrary number of times with new inputs before computing the final digest.

For example:

hash = new Hash('sha-256');
hash.update('some text');
hash.update('additional input');
finalOutput = hash.digest();

How does the update actually affect the input? Is the implementation dependant on the library?

For some context, I am using the crypto library in NodeJS and want to test the output of a function using a SHA-256 hash. To generate the output, I am calling the update function several times, and I want to be able to generate the same output in some online calculator in order to have an expected value to compare my actual output to.

0

There are 0 best solutions below