compchain-crypto

Compchain encryption library

Usage no npm install needed!

<script type="module">
  import compchainCrypto from 'https://cdn.skypack.dev/compchain-crypto';
</script>

README

compchain-crypto

Compchain encryption library

NPM

Installation

$ npm i --save compchain-crypto

Usage

const cc = require('compchain-crypto')
const assert = require('assert')

const privkey = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
const pubkey = '03a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd'
const msgObj = {
    first_name: 'Testy',
    last_name: 'McTesterson',
    email: 'testy@gmail.com',
    phone_code: '1',
    phone: '555-555-5555',
    country: 'USA',
    dob: '1-1-1970',
}

cc.encryptData(msgObj, pubkey)
.then( ciphertext =>
{
    console.log('ciphertext', ciphertext)
    cc.decryptData(ciphertext, privkey)
    .then( msg =>
    {
        console.log('msg', msg);
        assert.equal(msg, JSON.stringify(msgObj))
    });
});