示例
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
hash.update('some data to hash');
console.log(hash.digest('hex'));
// Prints:
// 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
参考:
https://www.cnblogs.com/chyingp/p/nodejs-learning-crypto-theory.html
官方文档