Add controls algorithm (encrypt.js)
This commit is contained in:
parent
1d34fb7828
commit
34c192b0bc
4 changed files with 9 additions and 9 deletions
|
@ -27,7 +27,7 @@ currentValue = readlineSync.setPrompt([prompt])
|
|||
|
||||
Sets the prompt, for example when you run `node` on the command line, you see `> `, which is node's prompt.
|
||||
`prompt` may be string, or may not be (e.g. number, Date, Object, etc.). This is converted to string (i.e. `toString` method is called) before it is displayed every time.
|
||||
For example: like bash `[foo-directory]# `
|
||||
For example: `[foo-directory]# ` like bash
|
||||
|
||||
```js
|
||||
readlineSync.setPrompt({toString:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var algorithmCipher = 'aes-256-cbc',
|
||||
cipher = require('crypto').createCipher(algorithmCipher, process.argv[2]),
|
||||
var cipher = require('crypto').createCipher(
|
||||
process.argv[2] /*algorithm*/, process.argv[3] /*password*/),
|
||||
stdin = process.stdin,
|
||||
stdout = process.stdout,
|
||||
crypted = '';
|
||||
|
|
|
@ -95,14 +95,16 @@ function _readlineShell(noEchoBack) {
|
|||
shellPath = 'cmd.exe';
|
||||
args = ['/V:ON', '/S', '/C',
|
||||
'%Q%' + __dirname + '\\read.bat%Q%' + optEchoBack +
|
||||
' |%Q%' + process.execPath + '%Q% %Q%' + __dirname + '\\encrypt.js%Q% %Q%' + password + '%Q%' +
|
||||
' |%Q%' + process.execPath + '%Q% %Q%' + __dirname + '\\encrypt.js%Q%' +
|
||||
' %Q%' + ALGORITHM_CIPHER + '%Q% %Q%' + password + '%Q%' +
|
||||
' >%Q%' + pathStdout + '%Q%' +
|
||||
' & (echo !ERRORLEVEL!)>%Q%' + pathStatus + '%Q% & (echo 1)>%Q%' + pathDone + '%Q%'];
|
||||
} else {
|
||||
shellPath = '/bin/sh';
|
||||
args = ['-c',
|
||||
'(' + shellPath + ' "' + __dirname + '/read.sh"' + optEchoBack + ')' +
|
||||
' |"' + process.execPath + '" "' + __dirname + '/encrypt.js" "' + password + '"' +
|
||||
' |"' + process.execPath + '" "' + __dirname + '/encrypt.js"' +
|
||||
' "' + ALGORITHM_CIPHER + '" "' + password + '"' +
|
||||
' >"' + pathStdout + '";' +
|
||||
' echo $? >"' + pathStatus + '"; echo 1 >"' + pathDone + '"'];
|
||||
}
|
||||
|
@ -110,9 +112,7 @@ function _readlineShell(noEchoBack) {
|
|||
stdin.pause(); // re-start in child process
|
||||
require('child_process').execFile(shellPath, args, {env: {Q: '"'}});
|
||||
|
||||
while (true) {
|
||||
if (fs.readFileSync(pathDone, {encoding: encoding}).trim() === '1') { break; }
|
||||
}
|
||||
while (fs.readFileSync(pathDone, {encoding: encoding}).trim() !== '1') {}
|
||||
if (fs.readFileSync(pathStatus, {encoding: encoding}).trim() === '0') {
|
||||
shellStdout =
|
||||
decipher.update(fs.readFileSync(pathStdout, {encoding: 'binary'}), 'hex', encoding) +
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "readline-sync",
|
||||
"description": "Synchronous Readline",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"homepage": "https://github.com/anseki/readline-sync",
|
||||
"author": {
|
||||
"name": "anseki"
|
||||
|
|
Loading…
Reference in a new issue