Skip to content

Commit

Permalink
Minor fixes to gpg utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jun 24, 2022
1 parent b994cd7 commit 8f80e2b
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions js/core-commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,55 @@ Luwrain.addHook("luwrain.commander.panel.actions", ()=>{
return {name: "gpg-encrypt", title: "Зашифровать", action: (selected, marked)=>{
if (!selected)
return false;
const passwd = Luwrain.popups.text("Расшифровка файла", "Введите пароль:", "");
const passwd = Luwrain.popups.text("Шифрование файла", "Введите пароль:", "");
if (!passwd)
return true;
const passwdFile = selected + ".passwd";
Luwrain.writeTextFile(passwdFile, [passwd, Luwrain.escapeString("cmd", "123 \' 321")]);
Luwrain.writeTextFile(passwdFile, [passwd]);
Luwrain.newJob("sys", [
"gpg",
"-c",
"--cipher-algo", "aes",
"--passphrase-fd", "0",
"--no-tty",
Luwrain.escapeString("cmd", selected),
"<", Luwrain.escapeString("cmd", passwdFile)],
"<", Luwrain.escapeString("cmd", passwdFile),
";", "rm", "-f", Luwrain.escapeString("cmd", passwdFile)],
null, (ok, exitCode)=>{
// Luwrain.deleteFile(passwdFile);
if (ok)
Luwrain.message("Зашифровано", Luwrain.constants.MESSAGE_TYPE_DONE); else
Luwrain.message("Произошла ошибка при шифровании файла", Luwrain.constants.MESSAGE_TYPE_ERROR);
});
return true;
}
};
Luwrain.message("Произошла ошибка при шифровании файла", Luwrain.constants.MESSAGE_TYPE_ERROR);
});
return true;
}
};
});

Luwrain.addHook("luwrain.commander.panel.actions", ()=>{
return {name: "gpg-decrypt", title: "Расшифровать", action: (selected, marked)=>{
if (!selected)
return false;
const passwd = Luwrain.popups.text("Расшифровка файла", "Введите пароль:", "");
if (!passwd)
return true;
const passwdFile = selected + ".passwd";
Luwrain.writeTextFile(passwdFile, [passwd]);
Luwrain.newJob("sys", [
"gpg",
"--decrypt-file",
"--passphrase-fd", "0",
"--no-tty",
Luwrain.escapeString("cmd", selected),
"<", Luwrain.escapeString("cmd", passwdFile),
";", "rm", "-f", Luwrain.escapeString("cmd", passwdFile)],
null, (ok, exitCode)=>{
// Luwrain.deleteFile(passwdFile);
if (ok)
Luwrain.message("Расшифровано", Luwrain.constants.MESSAGE_TYPE_DONE); else
Luwrain.message("Произошла ошибка при расшифровании файла", Luwrain.constants.MESSAGE_TYPE_ERROR);
});
return true;
}
};
});

0 comments on commit 8f80e2b

Please sign in to comment.