Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nhz-io/nhz-io-hmac-sha1
https://github.com/nhz-io/nhz-io-hmac-sha1
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nhz-io/nhz-io-hmac-sha1
- Owner: nhz-io
- License: mit
- Created: 2017-11-10T12:15:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-10T15:41:02.000Z (about 7 years ago)
- Last Synced: 2024-09-28T08:36:42.566Z (3 months ago)
- Language: CoffeeScript
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.litcoffee
- License: LICENSE
Awesome Lists containing this project
README
# HMAC-SHA1 digest
[![Travis Build][travis]](https://travis-ci.org/nhz-io/nhz-io-hmac-sha1)
[![NPM Version][npm]](https://www.npmjs.com/package/@nhz.io/hmac-sha1)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](LICENSE)
[travis]: https://img.shields.io/travis/nhz-io/nhz-io-hmac-sha1.svg?style=flat
[npm]: https://img.shields.io/npm/v/@nhz.io/hmac-sha1.svg?style=flat