This is an NPM module which exposes two functions which are used for generating and helping verify share codes for the FT.
The encrypt function, encrypt(userId, articleId, salt, time, tokens, context=defaultContext), will return a share code for your application to use.
The decrypt function, decrypt(code, article, salt), will return
{
tokens: tokens,
time: time,
user: user,
context: context
};
The decrypt function does not verify if the User ID actually corresponds with a User account, it if for your application to do those checks.
This requires Node.JS to be installed on your system alongside NPM.
Check-out the repository and run npm install
in the directory. If that has worked you should now be able to run npm test
, which should return all tests as passing. You are now ready to develop.
npm test
https://www.npmjs.com/package/node-rsa
var NodeRSA = require('node-rsa');
var key = new NodeRSA({b: 512});
var text = 'Hello RSA!';
var signature = key.sign(text, 'base64', 'utf8');
var checkSig = key.verify(buffer, signature, 'utf8', 'base64');