0.0.1 • Published 3 years ago

encryption-handler v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

encryption-js-lib

A simple lib o facilitate interaction with the encryption api.


get ready:

1-) install the package

npm install encryption-handler --save

2-) set the env variable ENCRYPTION_URL, or run the encryption-api locally.

ENCRYPTION_URL=<my_beautiful_dns>

examples:

as string

import { encrypt, decrypt } from 'encryption-handler';

const optionsToEncrypt = {
    id: '60c8add20cdf0aef292dbfb0',
    payload: 'a top secret message for the aliens'
};
const encrypted = await encrypt(optionsToEncrypt);
console.log(encrypted);
//-----BEGIN PGP MESSAGE-----\n\nwV4DOvUdyTtOIm0SAQdATgIJqPd4W1vkSH7ByHw5d1fnWW6UUUycO8DiYQMZ\nfWAwybTvYev+IFL1OosTYUPEY0bvjhlZCvpPW+PXvBXBXjgMIkjVl4z13F/a\n2TrACwjR0lQBNoZvIA6HRAkgwTeopJxTseKrRsjk08aNEQCZn9UZ1F9GouzI\nAn70w1fxId3QLR8rnRvNH27Ro7eH2tYhPVbgczbrR4Zq45WT1SpXKBoT3yGt\nx0k=\n=sSjE\n-----END PGP MESSAGE-----\n

const optionsToDecrypt = {
    id: '60c8add20cdf0aef292dbfb0',
    payload: encrypted
};
const decrypted = await decrypt(optionsToDecrypt);
console.log(decrypted);
//a top secret message for the aliens

as object

import { encrypt, decrypt } from 'encryption-handler';

const optionsToEncrypt = {
    id: '60c8add20cdf0aef292dbfb0',
    payload: {
        top:'information here',
        please: 'do not share'
    }
};
const encrypted = await encrypt(optionsToEncrypt);
console.log(encrypted);
//-----BEGIN PGP MESSAGE-----\n\nwV4DOvUdyTtOIm0SAQdAH0lgos8tby9v6YzrdZlU1cQ7/uEgAO4As9EkdzDk\nKCowya96285o51BxJ2cGE4PezMHkPMWH/J2uB4MUGgvavU2aCf5US4i1T7eO\npMZ0wwbf0mMB+MJkW0H5mDuPF5lBTT+1ermhFW1clGtjp8/RdE/qpEOIQRbB\n1nL73WVxFvtZSCmolb/bdeRbiTm16skSwzWMowaMEY4oidOzHowft4Lkqt9V\n+9h/r5U0QLHodLjwVuXOmyA=\n=jdd2\n-----END PGP MESSAGE-----\n


const optionsToDecrypt = {
    id: '60c8add20cdf0aef292dbfb0',
    payload: encrypted
};
const decrypted = await decrypt(optionsToDecrypt);
console.log(decrypted);
//{ top:'information here', please: 'do not share' }

Have fun 🙃