Как хэша с Crypto node.js

//Hash something.
crypto = crypto || require('crypto');
const createHash = crypto.createHash;
function sha1(txt) {
	return createHash('sha1') // <-- You can use other than sha1
  		.update(txt) //set what to encode
  		.digest('hex') //basically another way to encode. hex is base16 so for example doing .digest('base64') encodes 4x more effenciently
}
const hash = sha1('password');
hash == sha1('password')?'yes':'no'; //yes
Charming Chimpanzee