node-triplesec
A CommonJS module for symmetric key encryption of smallish secrets
How to install
npm install triplesec
How to Use
One-shot Mode
require 'triplesec' key = 'top-secret-pw'pt0 = 'the secret!'pt1 = pt0encrypt keydata : pt1 decrypt keydata : ciphertext consolelog "Right back the start! is "
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:
require 'triplesec' key = 'top-secret-pw'enc = key dec = key pt0 = 'the secret!'pt1 = pt0pt2 = pt0encrun data : pt1 encrun data : pt2 decrun data : ct1 decrun data : ct2 consolelog "Right back the start! is is "
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).
encrun data : pt1 encresalt encrun data : pt2