A module with a better and standard API exists
This object is returned by crypto.createHash() and allows the user to successively add more string data to be hashed, and to extract digests along the way.
|Hasher.update(string)||function||Add more data to the string we want to create a hash of. Takes one string argument, which is the new data we want to add.|
|Hasher.digest(string)||function||Return a digest from the data added (using update()) to the Hasher object so far. Takes one string argument, which is the encoding format to return. This can be either "base64", "base64url", "base64rawurl", "hex" or "binary". See the examples below for details.|
The above code sample should produce this in its output: