The crypto
module of node.js (at the time of this writing at least) is not still deemed stable and so the API may change. In fact, the methods that everyone in the internet use to get the hash (md5, sha1, ...) of a file are considered legacy (from the documentation of Hash
class) (note: emphasis mine):
Class: Hash
The class for creating hash digests of data.
It is a stream that is both readable and writable. The written data is used to compute the hash. Once the writable side of the stream is ended, use the read() method to get the computed hash digest. The legacy update and digest methods are also supported.
Returned by crypto.createHash.
Despite hash.update
and hash.digest
being considered legacy, the example shown just above the quoted snippet is using them.
What's the correct way of obtaining hashes without using those legacy methods?