In my application I am using encryption and decryption.
Before entering the string in to local database, I am encrypting that and after fetching the data from database I am decrypting it and using in my application.
It is working fine. I have used encryption/decryption from
link below
At the time of Encrypting:
NSString *myKey=@"any string more than 8 char";
NSData *data ;
NSData *encryptedData;
NSString *encryptPassword,*encryptPasscode;
// 1) Encrypt
data = [password dataUsingEncoding: NSASCIIStringEncoding];
encryptedData = [data AESEncryptWithPassphrase:myKey];
// 2) Encode Base 64
[Base64 initialize];
encryptPassword = [Base64 encode:encryptedData];
At the time of Decrypting :
NSData *decryptedData;
NSData *b64DecData;
field1 = (char *) sqlite3_column_text(selectPasscodeStatement, 0);
NSString *fieldStr1 = [[NSString alloc] initWithUTF8String: field1];
// 3) Decode Base 64
b64DecData = [Base64 decode:fieldStr1];
// 4) Decrypt
decryptedData = [b64DecData AESDecryptWithPassphrase:myKey];
retrivedPasscode = [[NSString alloc] initWithData:decryptedData encoding:NSASCIIStringEncoding];
But I have made staticLibrary of that same project. I am using that staticLibrary in another project. When I run that project, at the time of encrypting it gave me error below
-[NSConcreteMutableData AESEncryptWithPassphrase:]: unrecognized selector sent to instance 0x6a3fe40
You need to make change in the Build Settings of the project which will link the static library with the main project.
Follow these steps:
1)Click on Build Settings tab.
2)Search for “Other Linker Flags”.
3)Add ‘-all_load’ flag to it.
4)Build and run the project.
It worked fine for me.