Hi guys,

so I have finally found some time to get the tests and a proof of concept
of pgpbox running, since my arrival in Sydney. You can try it out at:
http://0-0-6-snapshot.pgpbox-org.appspot.com/pgpbox.html

Just drag a PDF onto the dotted area it's contents will be read via the
FileReader, encrypted, decrypted and finally rendered with pdf.js. This
works reasonably fast with PDFs of a couple hundred KB.

One problem I'm facing is that the FileReader and pdf.js store the PDF in
an ArrayBuffer, but openpgp.js only takes Strings. Also, it seems to have
trouble with unicode Strings, so I also convert the string to base64 before
encryption. Here's the current pipeline:

FileReader -> *ArrayBuffer -> Unicode -> Base64 -> Encrypt -> Decrypt ->
Base64 -> Unicode -> ArrayBuffer* -> pdf.js  (the encrypted PDF will later
be uploaded to a server after encryption of course ;)
*
*
Apart from the fact that this is not very efficient, as you can imagine, it
requires quite a large amount of memory (in bytes) to store the encrypted
PDF:


ArrayBuffer size: 678
Unicode size: 678
Base64 size: 2712
Cipher size: 4826
Base64Dec size: 2712
UnicodeDec size: 678
Decrypted ArrayBuffer size: 678

I put the qunit tests up under the following URL:
http://0-0-6-snapshot.pgpbox-org.appspot.com/qunit.html

The firsts 6 tests should run just fine in Chrome 16.0.912.77 (you may have
to refresh twice, since the qunit tests are asychronous and sometimes have
trouble the first time around???). The 7th test fails, since I dont encode
the unicode string to base64 before encryption. First question: Is this a
bug or a feature?

Second question: Is it somehow possible or is it outside the scope of
openpgp.js to take an ArrayBuffer as input/output? Aside from the fact,
that this would be a killer feature for the encryption of large files, it
would also make the library way more flexible ;) I hope I'm not sounding
too demanding :/ Looking forward to your feedback. Thanks!

Kind regards,
Tankred
_______________________________________________

http://openpgpjs.org

Reply via email to