the problem is that when decoding an image for example, I get a corrupted binary data, I've tried to convert it to base64, but it is invalid to display, is there a solution to decrypt pgp encrypted images valid
I am using this library, tell me it is valid for decrypting binary? http://openpgpjs.org/
ENCRYPT:
var key = request.data.publicKey;
var publicKey = openpgp.key.readArmored(key);
var base64Message = request.data.message;//btoa(request.data.message); // encoding binary data directly
openpgp.encryptMessage(publicKey.keys, base64Message).then(function(pgpMessage) {
console.log('encrypted');
console.log(pgpMessage);
sendResponse({result: pgpMessage});
}).catch(function(error) {
console.log(error);
});
DECRYPTING:
var key = openpgp.key.readArmored(request.data.privateKey);
console.log(key);
if(key.keys.length > 0)
{
key = key.keys[0];
key.decrypt(request.data.password);
var message = openpgp.message.readArmored(request.data.message); // error can't read pgp encoded binary data
openpgp.decryptMessage(key,message).then(function(plaintext) {
//do stuff...plaintext - is binary data in text
});
}
I encode binary directly, and then trying to decode but I get an error that:
Unknown ASCII armor type