Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypting the Video file in SD-CARD in react native

I was able to successfully encrypt and decrypt the videos using AES encryption. It worked good for smaller videos while for the bigger files it gave us the memory out/Overflow exception. Is there a better way to safe guard the video files where only my application can have the access to it. I am using this library "node-forge"

How are Video streaming apps like Netflix and Amazon prime are securing the videos locally, which are accessible only through their apps. If they are decrypting the whole file, how is the process so fast?

I was just wondering if we can just corrupt the file and de-corrupt while converting to base-64 ?

EDIT: This is a E-learning application where videos are accessed through SD Card securely. These Videos should be secured and can be played in only our app.

like image 546
Pruthvi Avatar asked Jan 07 '19 09:01

Pruthvi


People also ask

How do I encrypt a file in react native?

To encrypt a file you will need to know its location in the file system. For images you can use React Native API, or a library such as react-native-image-picker or react-native-camera-roll-picker. import { virgilCrypto } from 'react-native-virgil-crypto'; const keypair = virgilCrypto.

How do I encrypt a video file?

Right-click (or press and hold) a file or folder and select Properties. Select the Advanced button and select the Encrypt contents to secure data check box. Select OK to close the Advanced Attributes window, select Apply, and then select OK.

How do you encrypt and decrypt a string in react JS?

To encrypt and decrypt data, simply use encrypt() and decrypt() function from an instance of crypto-js. var bytes = CryptoJS. AES. decrypt(ciphertext, 'my-secret-key@123');


1 Answers

You need to design your security measures based on your requirements which is a very complex process and you need to consider a lot of details. In one hand you need to design a suitable protocol for your application, and in the other hand you should try to make it secure.

As suitability of design, for example, you need to consider how you are going to playback your video or how much disk/memory you have. In cases like Netflix which they playback video while downloading, they they probably use streaming modes of encryption algorithms. But As I said, without understanding complete design of your application, suggesting encryption methods is somehow unethical.

Update:

If a simple encryption is what you need, I suggest you to use a streaming method(like CTR). In this case, you can decrypt your content on-fly rather than completely decrypting your files first. But you need to feed this content into your player. This may be a little problem if you have not written your own player. I did this once by hooking file read/write APIs and did similar thing that you need, so it is possible.

like image 140
Afshin Avatar answered Oct 20 '22 15:10

Afshin