Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encryption of a native File using streams #255

Open
hennedo opened this issue Feb 25, 2023 · 0 comments
Open

Encryption of a native File using streams #255

hennedo opened this issue Feb 25, 2023 · 0 comments

Comments

@hennedo
Copy link

hennedo commented Feb 25, 2023

Hello,

I saw there is already an issue #230 regarding support for native files, also a PR #232 which helps using these files. I'm not sure if it would have been better to add to one of those as this asks for a different approach.

The native File API also exposes a ReadableStream which seems to be, at least in my testing with firefox, directly read from storage and is not loaded into RAM. My understanding is that the proposed PR #232 creates an ArrayBuffer containing the whole file, which will propably result in poor performance when encrypting huge files. In the code of penumbra I found the encryptStream function, which is currently not exposed, would it be possible to expose a wrapper of this and then attach the readable stream of the native file to the encryptStream function?

The exposed encryptStream function could have the same parameters as encrypt but accepts a ReadableStream as second parameter. It could return a ReadableStream with the encrypted data which will in theory at least halve the RAM workload as one does not need to store the whole file in an ArrayBuffer to pass it to the encrypt function and then also store it somewhere (or stream it somewhere) a second time..

It's the first time I'm using Streams in Javascript and I hope I did not misunderstand anything..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant