You should really use the built-in crypto module for your encryption needs. It's basically a binding to OpenSSL, a fast, stable, secure, and well-vetted crypto library. Trying to implement your own crypto (or use someone else's unvalidated attempt at implementing crypto) is a recipe for disaster.
If you're looking to encrypt data, all you have to do is call crypto.createCipher
, which returns a readable/writable Stream
. Write data into the stream and it will emit data events with the encrypted data.
For example:
var stream = crypto.createCipher('aes192', 'mysecretpassword');
stream.on('data', function(enc) {
// enc is a `Buffer` with a chunk of encrypted data
});
stream.write('some secret data');
stream.end();