-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I am able to encrypt and decrypt the contents of a text file using the browserPGP tool.
This is my encryption code. I am not including the input of key from a textbox.
const publicKeys = await Promise.all(publicKeysArmored.map(armoredKey => openpgp.readKey({ armoredKey })));
var blob = new Blob(["Lorem Ipsum is simply dummy text of the printing and typesetting industry. "], { type: "text/plain;charset=utf-8" });
//saveAs(blob,'decrypted.txt');
var file = new File([blob], "plaintext.txt", { type: "text/plain", });
var fileReader = new FileReader();
fileReader.onload = function()
{
const message = await openpgp.createMessage({ text: fileReader.result});
const encrypted = await openpgp.encrypt(
{
message,
encryptionKeys: publicKeys
});
var blob3 = new Blob([encrypted],{type: 'text/plain'} );
saveAs(blob3, 'encrypted.txt');
}
fileReader.readAsText(file);
}
However, I am not able to encrypt and decrypt a zip file. The decrypted zip file is always corrupt.
I use the same code, but convert the zip file contents into plaintext, which I think is not a good idea.
var zipFile = new JSZip();
zipFile.file("Metadata.txt", 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. ');
var plaintextbytes = new Uint8Array(zipFile);
var plainTextString = new TextDecoder().decode(plaintextbytes);
const message = await openpgp.createMessage({ text: plainTextString });
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels