@nhz.io/hmac-sha1

1.0.3 • Public • Published

HMAC-SHA1 digest

Travis Build NPM Version

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 secret

Complete invocation if possible

  if message then hmac message else hmac

Exports

module.exports = digest

Test

assert = require 'assert'

pass = '0caf649feee4953d87bf903ac1176c45e028df16'

Test curried

assert.strictEqual ((digest 'secret') 'message'), pass

Test full args

assert.strictEqual (digest 'secret', 'message'), pass

console.log 'pass'

Version 1.0.3

License MIT

Readme

Keywords

Package Sidebar

Install

npm i @nhz.io/hmac-sha1

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • nhz-io
  • ishi.ruy