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