1.0.3 • Published 8 years ago
@nhz.io/hmac-sha1 v1.0.3
HMAC-SHA1 digest
crypto = require 'crypto'Curry secret to allow reuse
hmacSha1 = (secret) -> (message) ->
hmac = crypto.createHmac 'sha1', secret
hmac.update message, 'utf8'
hmac.digest 'hex'
digest = (secret, message) ->Start curried
hmac = hmacSha1 secretComplete invocation if possible
if message then hmac message else hmacExports
module.exports = digestTest
assert = require 'assert'
pass = '0caf649feee4953d87bf903ac1176c45e028df16'Test curried
assert.strictEqual ((digest 'secret') 'message'), passTest full args
assert.strictEqual (digest 'secret', 'message'), pass
console.log 'pass'