Skip to content

Generates and verifies signatures

License

Notifications You must be signed in to change notification settings

lagden/signature

Repository files navigation

@tadashi/signature

NPM version Build Status Coverage Status


Generates and verifies signatures

Install

$ npm i -S @tadashi/signature

Usage

Generate

import {generate} from '@tadashi/signature'

const algorithm = 'sha1'
const payload = '{}'
const secret = 'a7fee042a2e1a9fa27cfc6931949ffe1'

const signature = generate(algorithm, payload, secret)
// => sha1=61ca6afb7b2752e106c939df11bbd7ca883b8166

Verify

import {verify} from '@tadashi/signature'

const signature = 'sha1=61ca6afb7b2752e106c939df11bbd7ca883b8166'
const payload = '{}'
const secret = 'a7fee042a2e1a9fa27cfc6931949ffe1'

const isValid = verify(signature, payload, secret)
// => true

API

generate(algorithm, payload, secret)

parameter type required description
signature string yes Algorithm that will be used
payload string yes Data to generate
secret string yes Some expression

verify(signature, payload, secret)

parameter type required description
signature string yes Algorithm used + hash e.g. sha1=61c...675
payload string yes Data used to generate the hash
secret string yes The same expression used to generate

Donate ❤️

  • BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4

License

MIT © Thiago Lagden

FOSSA Status