Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to hash with 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
 
PREVIOUS NEXT
Tagged: #hash #crypto
ADD COMMENT
Topic
Name
8+3 =