iosobjective-cencryptionrncryptor

Multiple encryption append to a file


I have a log of a programs state. This log can be manualy or time interval saved on a file for persistant storage. Before saving it to the file it is encrypted with RNCryptor.

My current appending(saving) to file flow:

  1. Read file
  2. Decript information from the read string
  3. Concat decrypted string with the new string
  4. Encrypt the concatenated string
  5. Write it to file

What I imagine:

  1. Encode new string
  2. Append to file

When I read this I will have to build a string from all the encoded strings. But I don't know how to decrypt the file with multiple encrypted blocks in it. How to differentiate where one ends and another begins. Also is this the best performance choice. The text in the file at maximum could get to 100MB(Possibly it will never get this big). Is using Core Data viable? Each append as different record or something. And core data could be encrypted so no need for RNCryptor.

Would appreciate code in Objective-C if any.


Solution

  • There are many things you can do: