Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may look at different approaches for soulution of your problem.</p> <ul> <li><p>Encrypt values, stored in CoreData with md5 + salt encryption. You can generate special key, based on user device UUID and some additional "salt" to store data. Be careful, Apple is going to depreciate device personalization values in future. But on the other side, you may recieve special key by user authentification and recieving this key from post request. For encryption you can use built in framework: <code>#import &lt;CommonCrypto/CommonDigest.h&gt;</code>. There are a lot of examples which you can find on the web.</p></li> <li><p>Encrypt whole sqlite file in documents folder. This can me quite tricky, and and have not faced this approach before.</p></li> </ul> <p>EDIT: This is code sample which you can use to receive encrypted with md5 data: This is .h file</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface NSString (MyExtensions) - (NSString *) md5; @end @interface NSData (MyExtensions) - (NSString *)md5; @end </code></pre> <p>this is .m file:</p> <pre><code>#import "MyExtensions.h" //here should be your .h file name #import &lt;CommonCrypto/CommonDigest.h&gt; // Need to import for CC_MD5 access @implementation NSString (MyExtensions) - (NSString *) md5 { const char *cStr = [self UTF8String]; unsigned char result[16]; CC_MD5( cStr, strlen(cStr), result ); // This is the md5 call return [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]; } @end @implementation NSData (MyExtensions) - (NSString *)md5 { unsigned char result[16]; CC_MD5( self.bytes, self.length, result ); // This is the md5 call return [NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7], result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15] ]; } @end </code></pre> <p>So if you include this files to any place of your code, you can simply call this function:</p> <pre><code>NSString *myStringToEncrypt = @"Confidential information"; NSString *myMD5 = [myStringToEncrypt md5]; </code></pre> <p>btw: you should know, that <strong>MD5 function</strong> is just hash function, which returns you control sum of data. If you want to <strong>encrypt</strong>, you could look at <strong>AES256</strong> encryption method. CommonCrypto also provides it. Approach depends on your goals.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload