added: command to decrypt text
This commit is contained in:
parent
89cedfa56a
commit
37bc8a235a
19
main.js
19
main.js
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue