From 37bc8a235aff31d8dbd15af4af173952dfd9fa35 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 21 Sep 2023 20:56:13 +0200 Subject: [PATCH] added: command to decrypt text --- main.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main.js b/main.js index 4423834..47dd078 100644 --- a/main.js +++ b/main.js @@ -353,6 +353,10 @@ var commands = [ { hint: "Edit pgp keys", action: editpgpkeys +}, +{ + hint: "Decrypt text", + action: decrypttext }]; var snippets = [ @@ -881,6 +885,21 @@ function editsettings() }); } +async function decrypttext() +{ + var key = localStorage.getItem("pgpkeys").split("-----END PGP PUBLIC KEY BLOCK-----")[1]; + var privateKey = await openpgp.readKey({ armoredKey: key }); + var decrypted = await openpgp.decrypt({ + message: await openpgp.readMessage({ armoredMessage: md.value }), + decryptionKeys: privateKey }); + const chunks = []; + for await (const chunk of decrypted.data) { + chunks.push(chunk); + } + md.value = chunks.join(''); + resize(); +} + function editpgpkeys() { bindfile(