I'm just sounding things out about this having looked around for a while and drawn a blank. I'd like to see if this is even possible as so far I can't see a way to do it.
I want to encrypt a file locally (in the browser using existing libraries) before uploading it. Then I'll need to retrieve it and decrypt it before presenting the file to the user. Specifically, I can't send the file to the server for encryption before storage. Encryption/decryption needs to be performed client side.
Here's a rough flow of what I need to do:
- Present user with a find-file widget.
- Read file into client side script (i.e. load it locally)
- Encrypt it on the client.
- Upload encrypted version, flush the client side and store the data.
And, in reverse:
- Download the stored, encrypted version of the file.
- Decrypt it on the client.
- Present the decrypted file back to the user as a download.
I've been looking for some kind of MIME encoding on the client (similar to the way email attachments are MIME encoded before being sent as plain text). I'm particularly interested in a jQuery method, as that's what the rest of my app is using, but plain old javascript would be fine.
Any thoughts or pointers very gratefully received. This is the one I'm mulling over the holidays. So, thanks in advance for any comments.