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

How to encrypt a Video File #21

Open
Pruthvirajcodewave opened this issue Dec 5, 2018 · 4 comments
Open

How to encrypt a Video File #21

Pruthvirajcodewave opened this issue Dec 5, 2018 · 4 comments

Comments

@Pruthvirajcodewave
Copy link

Pruthvirajcodewave commented Dec 5, 2018

Below is how to encrypt a text. Is there a way to encrypt video file by passing the path ?

const encrypt = (text, keyBase64) => {
var ivBase64 = "base64 random 16 bytes string";
return Aes.encrypt(text, keyBase64, ivBase64).then(cipher => ({ cipher, iv: ivBase64 }));
};

@Pruthvirajcodewave Pruthvirajcodewave changed the title How to encrypt a File How to encrypt a Video File Dec 5, 2018
@nabeelItilite
Copy link

same issue here. what is the basic idea to encrypt any kind of file ?

@mrmurphy
Copy link

mrmurphy commented Oct 3, 2021

@Pruthvirajcodewave @nabeelItilite you've likely moved on from this by now, but with the current API you'd need to load the entirety of the file from disk into a base64 string and then pass it across the bridge to be encrypted. I don't recommend doing this, as it'd be quite slow.

I need to encrypt media files in the app I'm working on, so even though it'll take some native work, I plan to fork this repository, and add a couple of native functions on both the iOS and Android sides for encrypting files on-disk, without having to go across the JS bridge. Luckily, @tectiv3 has already done almost all the work required for this, and it should be relatively simple to follow the existing code on each platform and make functions for encrypting files by path.

Each side would have to use native APIs to:

  • Load the file from the path passed into an array buffer in memory
  • Encrypt the data using the key and IV specified by the caller
  • Write the encrypted data back to disk, maybe in a temp folder, or maybe alongside the original location with a new prefix
  • Fulfill the result of the promise returned by the function with the path of the new file

@genaris
Copy link

genaris commented Jan 20, 2023

@mrmurphy It's been a while since you commented here but I'm wondering if you managed to add this feature in a fork. If that's the case could you open a PR here? I'm in need of exactly the same thing. Thank you!

@andresmejia3
Copy link

@mrmurphy I was wondering the same thing too

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

5 participants