Skip to content
Triple Security for the browser and Node.js
JavaScript HTML CoffeeScript C Makefile Shell
Latest commit e22dd6b Mar 31, 2016 @maxtaco maxtaco Merge pull request #54 from ericmj/patch-1
Fix number of keys generated by scrypt
Failed to load latest commit information.
browser Fix bug from bad ICS; upgrade to 108.0.8 and rebuild Aug 27, 2015
codo codo regen, and doc tweaks Oct 22, 2013
contrib add SHA-384 Apr 13, 2014
dev fixup the main.c from inside scrypt Nov 16, 2013
ext ready! Sep 2, 2013
lib Fix bug from bad ICS; upgrade to 108.0.8 and rebuild Aug 28, 2015
logo no spaces please! Sep 16, 2013
ref @filosotille found a bug in which the endianness was reversed for XSa… Nov 7, 2013
rel releases Jun 4, 2014
site upgraded anatomy img Dec 10, 2013
spec @filosotille found a bug in which the endianness was reversed for XSa… Nov 7, 2013
src don't copy extra keymaterial out; just pass reference Aug 27, 2015
talks/hack-and-tell 2013.10.22.key this is worth a shot Oct 24, 2013
test Fix bug from bad ICS; upgrade to 108.0.8 and rebuild Aug 28, 2015
.codoopts start work on documentation of API... Sep 14, 2013
.gitignore more ignoring Nov 16, 2013
.npmignore some more ignoring for smaller keybase client tarball Feb 6, 2014
.travis.yml only v0.10 Jun 4, 2014
CHANGELOG.md Fix bug from bad ICS; upgrade to 108.0.8 and rebuild Aug 28, 2015
LICENSE Initial commit Aug 28, 2013
Makefile Use iced-lock rather than copy-pasting the lock impl Aug 16, 2014
README.md fix some bugs in the readme Sep 17, 2013
SIGNED.md v3.0.25 Aug 27, 2015
bower.json in prep for push May 31, 2015
index.html Fix number of keys generated by scrypt Apr 1, 2016
package.json v3.0.25 Aug 28, 2015
triplesec_now_in_python.html working on site for v3 Nov 26, 2013
triplesec_standalone.html added standalone page - should be built dynamically Nov 14, 2013

README.md

node-triplesec

A CommonJS module for symmetric key encryption of smallish secrets

How to install

npm install triplesec

How to Use

One-shot Mode

{encrypt, decrypt} = require 'triplesec'

key = new Buffer 'top-secret-pw'
pt0 = new Buffer 'the secret!'
pt1 = new Buffer pt0
encrypt { key, data : pt1 }, (err, ciphertext) ->
    decrypt { key, data : ciphertext }, (err, pt2) ->
        console.log "Right back the start! #{pt0} is #{pt2}"

Reusable Derived Keys

The most expensive part of TripleSec is to derive keys from your given passphrase. This is intentionally so to make it more expensive to crack your password in the case that your ciphertext is stolen. However, you can spread this expense over multiple encryptions if you plan to be encrypting more than once:

{Encryptor, Decryptor} = require 'triplesec'

key = new Buffer 'top-secret-pw'
enc = new Encryptor { key }
dec = new Decryptor { key }
pt0 = new Buffer 'the secret!'
pt1 = new Buffer pt0
pt2 = new Buffer pt0
enc.run { data : pt1 }, (err, ct1) ->
    enc.run { data : pt2 }, (err, ct2) ->
        dec.run { data : ct1 }, (err, pt3) ->
            dec.run { data : ct2 }, (err, pt4) ->
                console.log "Right back the start! #{pt0} is #{pt3} is #{pt4}"

If you want to resalt derived keys with every encryption, you should explicitly ask for that. Otherwise, salt will be reused to speed up encryption (and decryption).

enc.run { data : pt1 }, (err, ct1) ->
    enc.resalt {}, () ->
        enc.run { data : pt2 }, (err, ct2) ->

Full API Documentation

Documentation generated by codo is available here.

Something went wrong with that request. Please try again.