2015-04-01 09:34:31 +02:00
|
|
|
/*
|
|
|
|
* readlineSync
|
|
|
|
* https://github.com/anseki/readline-sync
|
|
|
|
*
|
2019-07-27 14:58:50 +02:00
|
|
|
* Copyright (c) 2019 anseki
|
2015-04-01 09:34:31 +02:00
|
|
|
* Licensed under the MIT license.
|
|
|
|
*/
|
|
|
|
|
2014-07-13 08:32:02 +02:00
|
|
|
var cipher = require('crypto').createCipher(
|
|
|
|
process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
|
2014-07-13 06:55:17 +02:00
|
|
|
stdin = process.stdin,
|
|
|
|
stdout = process.stdout,
|
|
|
|
crypted = '';
|
|
|
|
|
|
|
|
stdin.resume();
|
|
|
|
stdin.setEncoding('utf8');
|
|
|
|
stdin.on('data', function(d) {
|
|
|
|
crypted += cipher.update(d, 'utf8', 'hex');
|
|
|
|
});
|
|
|
|
stdin.on('end', function() {
|
|
|
|
stdout.write(crypted + cipher.final('hex'), 'binary', function() {
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
});
|