added: command to decrypt text

This commit is contained in:
quenousimporte 2023-09-21 20:56:13 +02:00
parent 89cedfa56a
commit 37bc8a235a
1 changed files with 19 additions and 0 deletions

19
main.js
View File

@ -353,6 +353,10 @@ var commands = [
{ {
hint: "Edit pgp keys", hint: "Edit pgp keys",
action: editpgpkeys action: editpgpkeys
},
{
hint: "Decrypt text",
action: decrypttext
}]; }];
var snippets = [ 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() function editpgpkeys()
{ {
bindfile( bindfile(