2

I want to lock a file (located in the Documents directory of my Application Bundle) programmatically using a password. Is there an API for that, or do i have to write my own encryption and decription mechanism?

I've allready searched on the internet, but i couldn't find the proper solution for my problem.

To be clearly, i want to store a NSDictionary to a file located in the Documents directory. There i'd simply use NSDictionary's method writeToFile:atomically: but there is no possibility to set a password?

Thanks for your help, Br Nic

NicTesla
  • 1,626
  • 5
  • 21
  • 35

1 Answers1

1

You can do that in two steps:

  1. convert your NSDictionary to NSData by using NSKeyedArchiver archivedDataWithRootObject

  2. encrypt/decrypt your NSData like explained in this S.O. topic

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • Hello, 2nd possibility looks great! I'll try that one, Thanks – NicTesla May 25 '11 at 10:47
  • @NicTesla: perfect, but you will need both steps, since en/decrypting works on NSData. Once you have verified that it works, you could accept the answer... – sergio May 25 '11 at 10:55