node-crypto

How do I use Node.js Crypto to create a HMAC-SHA1 hash?

穿精又带淫゛_ 提交于 2019-11-26 22:28:41
问题 I want to create a hash of I love cupcakes (signed with the key abcdeg ) How can I create that hash, using Node.js Crypto? 回答1: Documentation for crypto: http://nodejs.org/api/crypto.html var crypto = require('crypto') , text = 'I love cupcakes' , key = 'abcdeg' , hash hash = crypto.createHmac('sha1', key).update(text).digest('hex') 回答2: A few years ago it was said that update() and digest() were legacy methods and the new streaming API approach was introduced. Now the docs say that either