Encryptouflage
This is a module, that can encrypt and decrypt messsages.
About
With this module you can encrypt and decrypt any text message. This might be useful for encrypting Emails or Files in order to prevent third parties from monitoring the matter.
By default, the encrypted message is output in "lettered" format, camouflaging the message to automated email filters.
Usage
require the module
const encryptouflage = require('encryptouflage');
encrypt
encryptouflage.encrypt({ options })
options
:
- key
- instream
- outstream
- algorithm (optional)
- iv (optional)
- lettered (optional)
- key / password desired to encrypt with
- readable stream of data, that is to be encrypted
- writable stream, that the encrypted data is written to
- cipher algorithm used
-
default:
'AES-256-CTR'
- initialization vector
-
default
crypto.randomBytes(16)
- use "lettered" formatting
-
default:
true
example:
With lettered formatting
the initialization vector is added automatically.
const encryptouflage = require('./encryptouflage');
const fs = require('fs');
var input = fs.createReadStream('./input.txt');
var output = fs.createWriteStream('./output.encr');
var key = 'mysecretkey';
encryptouflage.encrypt({ instream: input, outstream: output, key: key });
With plain formatting
the initialization vector has to be handled manually.
const encryptouflage = require('./encryptouflage');
const fs = require('fs');
var input = fs.createReadStream('./input.txt');
var output = fs.createWriteStream('./output.encr');
var key = 'mysecretkey';
let iv = encryptouflage.encrypt({ instream: input, outstream: output, key: key, lettered: false });
output.on('close', function () {
fs.appendFileSync(output.path, iv);
});
decrypt
encryptouflage.decrypt({ options })
options
:
- key
- instream
- outstream
- iv
- algorithm (optional)
- lettered (optional)
- correct key / password to decrypt with
- readable stream of data, that is to be decrypted
- writable stream, that the decrypted data is written to
- initialization vector
- cipher algorithm used
-
default:
'AES-256-CTR'
- use "lettered" formatting
-
default:
true
example:
With lettered formatting
the original initialization vector is extracted automatically and therefore not required.
const encryptouflage = require('./encryptouflage');
const fs = require('fs');
var input = fs.createReadStream('./input.encr');
var output = fs.createWriteStream('./output.txt');
var key = 'mysecretkey';
encryptouflage.decrypt({ instream: input, outstream: output, key: key});
With plain formatting
the original initialization cannot be extracted automatically and is therefore required.
const encryptouflage = require('./encryptouflage');
const fs = require('fs');
var input = fs.createReadStream('./input.encr');
var output = fs.createWriteStream('./output.txt');
var key = 'mysecretkey';
var iv = Buffer.from('qLhMmT0icQrCyTcyWaeT7g==', 'base64');
encryptouflage.decrypt({ instream: input, outstream: output, key: key, lettered: false, iv: iv });
License
Encryptouflage is MIT licensed. You can find out more and read the license document here.