Is it possible to use a keychain like NSUserDefaults for steroids to store NSData?

Can Keychain be used NSUserDefaultson steroids? I mean, for example, store NSDataused in the game?

I intend to keep an element NSDatathat will be essentially a representation of an array or dictionaries.

So the questions are:

Suppose I create a shell using the Apple class KeychainItemWrapper. Is this kSecValueDataan object reference mentioned in the link documentation NSData?

If so, I can do it, right?

NSData *myData = [NSKeyedArchiver archivedDataWithRootObject:myArrayOfDicts];
KeychainItemWrapper* keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"myID" accessGroup:nil];
[keychain setObject:myData forKey:kSecValueData];

Second question: if so, is there a limit on the size NSDatathat can be stored in the keychain element?

+4
source share
1 answer

I don’t think there is any limit, and you can definitely store NSData, however the performance will not be very good. Indication of Apple documentation:

The keychain is designed to store small amounts of sensitive data specific to your application. It is not intended as a universal mechanism for encrypting and storing data.

I would not store more than 1 KB or so in the key record, and you should also avoid a large number of records in the keychain.

, AES-256 , AES. RNCryptor , - security.stackexchange.com.

NSUserDefaults. . , NSSearchPathDirectory, iCloud.

. , , . , / . LTE , .

, Apple , API -, .

+6

Source: https://habr.com/ru/post/1537037/


All Articles