To get the sha1 hash of a string in Node.js, we use the crypto
module.
For instance, we write
const crypto = require("crypto");
const shasum = crypto.createHash("sha1");
shasum.update("foo");
const hash = shasum.digest("hex");
to call createHash
to create a hash.
Then we call update
to add content to it.
Finally, we call digest
with 'hex'
to return the hash.