Straightforward encryption/decryption utility based on node-jose by Cisco
npm install easy-joseeasy-jose
=========


> Javascript Object Signing and Encryption standard
Straightforward encryption/decryption utility based on [node-jose] by Cisco
Getting Started
------------
Install via NPM
``bash
$ npm install --save easy-jose
`
Basic Usage
------------
Require the library, then initialize.
`js
const easyJose = require('easy-jose');
easyJose.init();
`
Optional Arguments:
- kty: key type, default is "RSA"
- size: size in bits, default is 2048
- isEncoded: boolean, base64 encode the public key, default is false
- isPadded: boolean, add padding to base64 encoding, default is false
Example:
`js
const keys = easyJose.generateKeys("EC", 4096);
`
Required Arguments:
- public_key
- payload: data to encrypt
Optional Argument
- isKeyEncoded: boolean, tell easyJose if you're using a base64 encoded public_key
Example:
`js
const encrypted = easyJose.encryptContent(public_key, payload);
`
Required Arguments:
- private_key
- payload: data to decrypt
Optional Argument
- isPayloadEncoded: boolean, tell easyJose if you're using a base64 encoded payload
Example:
`js
const decrypted = easyJose.decryptContent(private_key, encrypted);
`
`js
const easyJose = require('easy-jose');
const somedata = {
txt: 'hello'
};
(async () => {
easyJose.init();
const { private_key, public_key } = await easyJose.generateKeys();
console.log(private_key);
console.log(public_key);
const encrypted = await easyJose.encryptContent(public_key, somedata);
console.log(encrypted);
const decrypted = await easyJose.decryptContent(private_key, encrypted);
console.log(decrypted);
})();
`
Utilities
------------
`js
const encoded = easyJose.encode(raw);
`
`js
const decoded = easyJose.decode(base64EncodedString);
`
`js
const u8a = easyJose.convertToU8A(data);
`
`js
const data = easyJose.convertU8A(arrayBufferData);
``
Thanks
------
easy-jose* © 2018, Fernan de Dios. Released under the [MIT License].
> fernandedios.com ·
> GitHub @fernandedios ·
> Twitter @fernan_de_dios
[MIT License]: http://mit-license.org/
[node-jose]: https://github.com/cisco/node-jose