开发者

Lock file on iOS Device programmatically

开发者 https://www.devze.com 2023-03-08 11:24 出处:网络
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开发者_StackOverflow i have to write my own encryp

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开发者_StackOverflow 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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号