I\'ve trying to encrypt a Blob of pdf file and store it in the localStorage and read and decrypt it later when i\'m offline.
My app is written in AngularJS and the e
Your decryptPDF
function is returning a binary-encoded string, which is the native format forge v0.6.x works with. To convert that back to a Uint8Array do this instead:
decipher.finish();
return s2a(decipher.output.getBytes());
function s2a(str) {
var view = new Uint8Array(str.length);
for (var i = 0, j = str.length; i < j; i++) {
view[i] = str.charCodeAt(i);
}
return view;
}
You should also check the return value of decipher.finish()
to ensure it is true
. Otherwise, the decryption may have failed.