revolutionwhe.blogg.se

Node js bcrypt
Node js bcrypt













node js bcrypt

Var hashmd5 = crypto.createHash('md5').update(string).digest('hex') Ĭonsole.log('The MD5 hash of "%s" is %s', string, hashmd5) Var encrypted = crypto.createHmac('sha1', key).update(string).digest('hex') Ĭonsole.log('Encrypting "%s" using passphrase "%s": %s', string, key, encrypted) a hashed message authentication checksum (HMAC) using a shared secret key

node js bcrypt

Var buf = crypto.randomBytes(16).toString('base64') Ĭonsole.log('Random token of %d bytes in base 64: %s', buf.length, buf) Var buf = crypto.randomBytes(16).toString('hex') Ĭonsole.log('Random token of %d bytes in hexadecimal: %s', buf.length, buf) In companion with the answer, you should prefer bcrypt for password related stuff but still you can use crypto for a wide range of tasks like create random tokens or a HMAC checksum or SHA1/MD5 hashes: var crypto = require('crypto')















Node js bcrypt