• Stars
    star
    332
  • Rank 126,957 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 11 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Encryption enabled browser storage

crypt.io Build Status

crypt.io implements secures browser storage with the SJCL (Stanford Javascript Crypto Libraries) crypto library.

Options:

  • passphrase: {String} User supplied passphrase
  • storage: {String} Storage engine to use; local, session or cookies

Examples:

Here are a few examples of use to get you started.

Default use

Saving data...

var storage = cryptio
  , inventory = [{
      "SKU": "39-48949",
      "Price": 618,
      "Item": "Snowboard"
    }, {
      "SKU": "99-28128",
      "Price": 78.99,
      "Item": "Cleats"
    }, {
      "SKU": "83-38285",
      "Price": 3.99,
      "Item": "Hockey Puck"
    }];

storage.set('inventory', inventory, function(err, results){
  if (err) throw err;
  console.log(results);
});

Retrieving data...

var storage = cryptio;

storage.get('inventory', function(err, results){
  if (err) throw err;
  console.log(results);
});

Storage option

Want to use a different storage engine like the HTML5 sessionStorage feature?

var options = {
  storage: 'session',
};

Or some depreciated cookies? This is the least tested option

var options = {
  storage: 'cookies',
};

Extra security

While providing a transparent method of encryption for objects within the client prevents the need for user interaction, in terms of security in the event of a same-origin, dom rebinding attack coupled with a man- in-the-middle scenario or a malicious browser add-on it would be more secure to prompt the user for his/her passphrase.

Here is an example of user input for the passphrase.

var pass = window.prompt("Please enter password...", "a custom password");

var options = {
  passphrase: pass
};

storage.set(options, 'inventory', inventory, function(err, results){
  if (err) throw err;
  console.log(results);
});

storage.get(options, 'inventory', function(err, results){
  if (err) throw err;
  console.log(results);
});

For the paranoid

Here is a robust example of saving & retrieving data implementing a user defined password based on their input while also using key stretching techniques to further enhance the security of the key used as well as using a tempoary storage option such as sessionStorage for the current authenticated session.

Saving data (please keep in mind that a static value for the salt is not recommended)

var pass = window.prompt("Enter password to protect saved data", "");

var options = {
  passphrase: sjcl.codec.base64.fromBits(sjcl.hash.sha256.hash(sjcl.misc.pbkdf2(pass, sjcl.random.randomWords(2), 100000, 512)))
};

storage.set(options, 'inventory', inventory, function(err, results){
  if (err) throw err;
  console.log(results);
});

storage.get(options, 'inventory', function(err, results){
  if (err) throw err;
  console.log(results);
});

Warning:

For the obligitory read regarding Javascript Encryption and the security implications please read 'NCC Group - Javascript Cryptography Considered Harmful'

Requirements:

Installation:

Three methods are available for setup and use; using bower, cloning & manual

Yarn

To setup using yarn

%> yarn add crypt.io

Bower (depreciated)

To setup using bower

%> bower install crypt.io

Clone w/ git

To setup using git

%> git clone --recursive https://github.com/jas-/crypt.io.git

Manual

Copy the crypt.io.min.js and the sjcl libraries to your web project and include them like so.

<script src="/path/to/sjcl.js"></script>
<script src="/path/to/crypt.io.min.js"></script>

Support:

Found a bug? Want a feature added? General feedback or kudos? Please open an issue so I can address it. Thanks!

More Repositories

1

node-libnmap

API to access nmap from node.js
JavaScript
255
star
2

jQuery.pidCrypt

PKI key ring for your browser forms
JavaScript
40
star
3

proginoskes

Monitor your infrastructure in real time using ssh to centralize a stream of log events
JavaScript
39
star
4

comm.js

Native browser communications API; XHR, XDR, WS & WSS
JavaScript
35
star
5

jaks

Just Another Kickstart Script
13
star
6

node-spkac

Example app to demo node.js SPKAC support
HTML
10
star
7

libmasscan

node.js native extension for interfacing with the masscan tool as a shared object
C++
7
star
8

kruptein

crypto; from kruptein to hide or conceal
JavaScript
6
star
9

phpDHCPAdmin

Simple to use web interface for the ISC DHCPD service (WARNING: This project has not been updated in some number of years, the use of host based firewalling should protect as existing SQL and XSS vulnerabilities exists)
PHP
5
star
10

libzmap

node.js bindings for zmap network scanning tool
C
3
star
11

sqlSec

Encryption key/data rotation toolkit written in SQL (think poor mans PCI-DSS compliance for 'at rest' data)
PLpgSQL
2
star
12

SPKAC-PHP-OpenSSL

Patch for SPKAC support in PHP (see http://php.net/manual/en/migration56.openssl.php)
PHP
2
star
13

ulteo

A repository to store & maintain a patch providing CAS authentication for the Ulteo-OVD software
PHP
2
star
14

top-secret

This is a repo to test using symmetric encryption (as a profile alias command) to push/pull from various machines by creating compressed archive, encrypting, pushing to github or pulling from github, merging, decrypting & decompressing
Shell
2
star
15

MLIB-Inventory

Inventory management project
JavaScript
1
star
16

in-my-cloud

Experimental template project
JavaScript
1
star
17

UID2SID

Perl script to resolve UID to SID mapping during Samba/Winbind Active Directory Authentication
1
star
18

MLIB-Inventory-Server

RESTFul API for management of computing inventory assets
PHP
1
star
19

pam_krb5-ldap

Patch for RedHat's pam_krb5 (https://fedorahosted.org/pam_krb5/) extending functionality by providing LDAP support for UID/GID mapping
C
1
star