0

I have a table view that contain video files, I want to download this video file from url and show download progress for every cell , and after finishing downloading, I want to encrypt downloaded video file and when user want to open video I have to decrypt this and show to user. but I did not find a solution for encrypt and decrypt the video file. someone have any solution for encrypt and decryption for video file.

Tejas Pandya
  • 3,987
  • 1
  • 26
  • 51
ava
  • 1,148
  • 5
  • 15
  • 44
  • you want to encrypt and decrypt video right ? – Tejas Pandya Dec 15 '17 at 10:23
  • Can you show your approach that didn't work? Otherwise this will look like asking for code. – Andras M. Dec 15 '17 at 10:31
  • @Tej yes i want to encrypt and decrypt video file – ava Dec 15 '17 at 10:35
  • @AndrasM. i try convert video file to data and use this link for encryption and decryption but that is not work. And I do not know if my solution is right. https://github.com/RNCryptor/RNCryptor https://stackoverflow.com/questions/27072021/aes-encrypt-and-decrypt – ava Dec 15 '17 at 10:39
  • @AndrasM. i'm using this code for create data from video url: do { let weatherData = try NSData(contentsOf: url!, options: NSData.ReadingOptions()) print(weatherData) } catch { print(error) } – ava Dec 15 '17 at 10:43
  • @ava . Please have a look at [this](https://stackoverflow.com/a/41083395/6880611). you might find a proper library – Tejas Pandya Dec 15 '17 at 10:53
  • @Tej decryption result is data that we can convert to video? – ava Dec 15 '17 at 11:20
  • 1
    yes @ava. it will return bytes array . you can load video from this byte array . – Tejas Pandya Dec 15 '17 at 11:25
  • @Tej thanks for reply. – ava Dec 15 '17 at 11:29

1 Answers1

2

Just use iOS build-in Data Protection and the encryption and decryption will be done by iOS automatically on writing the file and reading the file.

Set completeFileProtection when writing the data:

static var completeFileProtection: NSData.WritingOptions { get }

The file is stored in an encrypted format and may be read from or written to only while the device is unlocked. At all other times, attempts to read and write the file result in failure.

See iOS Security Page 11: Encryption and Data Protection, File Data Protection.

zaph
  • 111,848
  • 21
  • 189
  • 228