Excuse me if this is a question that has been asked before, if so point me to the right answer.(i couldn't find the answer.)
My Question's:
I have an XML coming in from a NSUrl i need to be able to parse it appropriately, i will be receiving the responses with Field Perpetrators in them such as ().
Could i have it set up to search a dictionary for Keywords and parse them from the XML? If so what would be a good start on learning that?
Also is it possible to save the response's and encrypt them until i need to use them in another view? if so, what is the best way to encrypt on the IOS side?
any guide in the right direction is wonderf开发者_C百科ul!! I'm not asking for someone to answer all of them but it would be nice, thank you!
The method - (BOOL)writeToFile:(NSString *)path options:(NSDataWritingOptions)mask error:(NSError **)errorPtr
has NSDataWritingFileProtection
options that will encrypt the data for you but you have no control over they encryption key.
For encryption use CommonCrypro (part of iOS), aes128, cbc. But the real question is how will you securely save the encryption key?
Here is an encryption/decryption method:
+ (NSData *)doCipher:(NSData *)dataIn
iv:(NSData *)iv
key:(NSData *)symmetricKey
context:(CCOperation)encryptOrDecrypt
{
CCCryptorStatus ccStatus = kCCSuccess;
size_t cryptBytes = 0; // Number of bytes moved to buffer.
NSMutableData *dataOut = [NSMutableData dataWithLength:dataIn.length + kCCBlockSizeAES128];
ccStatus = CCCrypt( encryptOrDecrypt, // kCCEncrypt or kCCDecrypt
kCCAlgorithmAES128,
kCCOptionPKCS7Padding,
symmetricKey.bytes,
kCCKeySizeAES128,
iv.bytes,
dataIn.bytes,
dataIn.length,
dataOut.mutableBytes,
dataOut.length,
&cryptBytes);
if (ccStatus != kCCSuccess) {
NSLog(@"CCCrypt status: %d", ccStatus);
}
dataOut.length = cryptBytes;
return dataOut;
}
精彩评论