UNPKG

569 BJavaScriptView Raw
1/*
2 * readlineSync
3 * https://github.com/anseki/readline-sync
4 *
5 * Copyright (c) 2016 anseki
6 * Licensed under the MIT license.
7 */
8
9var cipher = require('crypto').createCipher(
10 process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
11 stdin = process.stdin,
12 stdout = process.stdout,
13 crypted = '';
14
15stdin.resume();
16stdin.setEncoding('utf8');
17stdin.on('data', function(d) {
18 crypted += cipher.update(d, 'utf8', 'hex');
19});
20stdin.on('end', function() {
21 stdout.write(crypted + cipher.final('hex'), 'binary', function() {
22 process.exit(0);
23 });
24});