My goal is to get an image form user encrypt it in the browser and upload it to the server. All of these things by themselves work. The only problem is when I start to put all of this together. When I get the file it’s represented as
File type. And I want to push it through port to JS where I encrypt it. I want to use
Bytes for this becasue
Base 64 wastes 30% of space and I don’t want to waste it just because of ports.
My initial idea was to
Base 64 encode it decode it in JS to Uint8Array encrypt it and do the encoding all over again in reverse. But I don’t think that it’s a good idea to do it on files because they are a little bit bigger. The overhead might be acceptable for uploads but I’m not sure if it would be acceptable for processing multiple files when viewing more images on the same page. Is there a better way to make it work?
For encryption I use Tweet nacl-js.