Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hotpacket

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hotpacket

HotPacket provides tools for javascript object encryption and encoding.

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

HotPacket

NPM

Build Status

WARNING THIS IS AN EXPERIMENT. DO NOT USE.

  • Crypto thanks to the very awesome SJCL

HotPacket provides tools for javascript object encryption and encoding.

Install

$ npm install hotpacket --save
var HotPacket = require('HotPacket');

or

<!-- dev -->
<script src="https://cdn.rawgit.com/OR13/hotpacket/master/dist/hotpacket.js"></script>

<!-- prod (but really did you read the warning?) -->
<script src="https://rawgit.com/OR13/hotpacket/master/dist/hotpacket.js"></script

Usage

HotPacket.init({ password: 'shared_secret' }); 

var newEnvelope = HotPacket.new({ 
    type: "update_name", 
    data: { id: 0, name: "billy" } 
});

console.log('newEnvelope: ', newEnvelope)

var encryptedEnvelope = HotPacket.encrypt(newEnvelope);

console.log('encryptedEnvelope: ', encryptedEnvelope)

var decryptedEnvelope = HotPacket.decrypt(encryptedEnvelope);

console.log('decryptedEnvelope: ', decryptedEnvelope)

console.log("HotPacket.isEqual(newEnvelope, decryptedEnvelope): ", HotPacket.isEqual(newEnvelope, decryptedEnvelope) );

console.log("are objects equal: ", newEnvelope === decryptedEnvelope);

console.log("are object strings equal: ",  JSON.stringify(newEnvelope) === JSON.stringify(decryptedEnvelope));

var myObject = {
    foo: "bar"
};

var env = HotPacket.new(myObject);

var b64Env = HotPacket.encodeBase64(env);

var expected = 'eyJ0eXBlIjoiSG90UGFja2V0RW52ZWxvcGUiLCJlbmNyeXB0ZWQiOmZhbHNlLCJib2R5Ijp7ImZvbyI6ImJhciJ9fQ==';

console.log('expect true: ', b64Env ===  expected);

var encoded = 'eyJ0eXBlIjoiSG90UGFja2V0RW52ZWxvcGUiLCJlbmNyeXB0ZWQiOmZhbHNlLCJib2R5Ijp7ImZvbyI6ImJhciJ9fQ==';

var expected = {
    foo: "bar"
};

var decoded = HotPacket.decodeBase64(encoded);

console.log('expect true: ', JSON.stringify(expected) === JSON.stringify(decoded.body));

Dev

$ npm run test
$ npm run build

FAQs

Package last updated on 04 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc