Files
miniproject_osl_nodejs/node_modules/jwt-simple/README.md
T
2016-04-01 14:09:55 +00:00

32 lines
792 B
Markdown

# node-jwt-simple
[JWT(JSON Web Token)](http://self-issued.info/docs/draft-jones-json-web-token.html) encode and decode module for node.js.
JWT is used by [Google In-App Payments](http://code.google.com/intl/en/apis/inapppayments/docs/index.html).
## Install
$ npm install jwt-simple
## Usage
var jwt = require('jwt-simple');
var payload = { foo: 'bar' };
var secret = 'xxx';
// encode
var token = jwt.encode(payload, secret);
// decode
var decoded = jwt.decode(token, secret);
console.log(decoded); //=> { foo: 'bar' }
### Algorithms
By default the algorithm to encode is `HS256`.
The supported algorithms for encoding and decoding are `HS256`, `HS384`, `HS512` and `RS256`.
// encode using HS512
jwt.encode(playload, secret, 'HS512')