Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Triple Security for the browser and Node.js
JavaScript HTML CoffeeScript C Other
Failed to load latest commit information.
browser Fix errant iced-coffee-script inclusion
codo codo regen, and doc tweaks
contrib add SHA-384
dev fixup the main.c from inside scrypt
ext ready!
lib Fix errant iced-coffee-script inclusion
logo no spaces please!
ref @filosotille found a bug in which the endianness was reversed for XSa…
rel releases
site upgraded anatomy img
spec @filosotille found a bug in which the endianness was reversed for XSa…
src Use iced-lock rather than copy-pasting the lock impl
talks/hack-and-tell 2013.10.22.key this is worth a shot
test Use iced-lock rather than copy-pasting the lock impl
.codoopts start work on documentation of API...
.gitignore more ignoring
.npmignore some more ignoring for smaller keybase client tarball
.travis.yml only v0.10
CHANGELOG.md Fix errant iced-coffee-script inclusion
LICENSE Initial commit
Makefile Use iced-lock rather than copy-pasting the lock impl
README.md fix some bugs in the readme
SIGNED.md v3.0.19
bower.json Add bower.json. Fixes #31; fixes #33
index.html small unfix
package.json v3.0.19
triplesec_now_in_python.html working on site for v3
triplesec_standalone.html added standalone page - should be built dynamically

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.