Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/you21979/node-simple-verify

GENERATE SECRET AND HMAC VERIFY
https://github.com/you21979/node-simple-verify

Last synced: 3 days ago
JSON representation

GENERATE SECRET AND HMAC VERIFY

Awesome Lists containing this project

README

        

# simple-verify

* GENERATE SECRET AND HMAC VERIFY

## install

```
npm i @you21979/simple-verify
```

## usage

### create Key and Secret

```
var verify = require('@you21979/simple-verify')
verify.createKeyPair().then(function(res){
// result data save
console.log(res)
})
```

### sign and verify

```
var verify = require('@you21979/simple-verify')
var argo = 'sha256'
var pair = {
key: '6b47121a-cfd5-4875-8345-da7517730afa',
secret: 'b4d31b0d9be238da31a3fdb2afccd31d803341810c66d82d8b5ca53f35d41609'
}

var data = JSON.stringify({
key : pair.key,
message : "test desu",
nonce : new Date().getTime(),
})

var signdata = verify.sign(argo, pair.secret, data)
if(verify.check(argo, signdata, pair.secret, data)){
console.log("check ok");
}else{
console.log("check ng");
}
```