SECURE JSON WEB TOKEN LIBRARY
Secure your payloads by adding an extra layer of encryption to your applications, especially when sending data across the internet.
Install
npm install securejwt
Usage
sjwt.setKeyPath(_path_)
Sets the locationt o store sjwt key and (re)generates key.
- _path_: <string>
sjwt.generateJWT(payload,fingerprint)
Returns JsonWebToken with aes256 encrypted payload. See JsonWebToken
- payload: <Object>|<Primitive>|<\Buffer>
- fingerprint: <string>
sjwt.retrieveJWT(JWTString,fingerprint)
Returns decrypted payload of JWTString
- JWTString: <string>
- fingerprint: <string>
Full Example
var sjwt = ; // require module /* Variables */var keyPath = "~/jwtkeys"; // define keypathvar payload = "message" : "hello" ; // define payloadvar fingerprint = "myFingerPrint"; // define fingerprint /* Methods */sjwt; // set key pathvar secureToken = sjwt; // generate secureTokenvar payload = sjwt; // decrypt payload /* Inspection */console; // output secureToken to inspect payloadconsole; // output payload to inspect