i have a plist with some stored data and want to encrypt decrypt so it's not readable using objective c. i've read about AES encryption etc but i want the whole plist to be encrypted some how not the strings in the plist....
any help will be really appreciated.
Using the code at https://web.archive.org/web/20150612123348/http://blog.objectgraph.com/index.php/2010/04/20/encrypting-decrypting-base64-encode-decode-in-iphone-objective-c/ (the link that you provided in comment), you can encrypt your plist by:
NSData *plistFileData = [NSData dataWithContentsOfFile:plistPath];
NSData *encryptedData = [plistFileData AESEncryptWithPassphrase:password];
[encryptedData writeToFile:encryptedPath atomically:YES];
plistPath is a NSString containing the path to the plist file you want to encrypt
password is the encryption key you would like to use
encryptedPath is where you want to save the encrypted file
to decrypt:
NSData *encryptedData = [NSData dataWithContentsOfFile:encryptedPath];
NSData *plistFileData = [plistFileData AESDecryptWithPassphrase:password];
[plistFileData writeToFile:plistPath atomically:YES];
encryptedPath is a NSString containing the path to the encrypted plist file
password is the encryption key you would like to use
plistPath is where you want to save the decrypted plist file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With