CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | Custom |
ReleasedLast Release | May 2016 |
Maintained by Fernando Arellano, Daniel Broad.
Provides a Core Data store that encrypts all data that is persisted. Besides the initial setup, the usage is exactly the same as Core Data and can be used in existing projects that use Core Data.
cd ~/Documents/code/YourApp
git clone https://github.com/project-imas/encrypted-core-data.git
Navigate to encrypted-core-data, highlight Incremental Store, and click Add
SQLCipher is added as a git submodule within ECD. A git submodule init
and git submodule update
should populate the sqlcipher submodule directory, where the sqlcipher.xcodeproj
can be found and added to your project.
-DSQLCIPHER_CRYPTO_CC
and -DSQLITE_HAS_CODEC
under the sqlcipher project settings > Build Settings > Custom Compiler Flags > Other C Flagssqlcipher
to Target Dependencies, and libsqlcipher.a
and Security.framework
to Link Binary With Libraries.$ sudo gem install cocoapods
in your terminal. (See the CocoaPods website for details.)pod init
to create a Podfile.pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
to your Podfilepod install
#import "EncryptedStore.h"
EncryptedStore is known to work successfully on iOS versions 6.0 through 9.2.
If you wish to set a custom cache size and/or custom database URL: create an NSDictionary to set the options for your EncryptedStore, replacing customPasscode, customCacheSize, and/or customDatabaseURL:
NSDictionary *options = @{ EncryptedStorePassphraseKey: (NSString *) customPasscode,
EncryptedStoreCacheSize: (NSNumber *) customCacheSize,
EncryptedStoreDatabaseLocation: (NSURL *) customDatabaseURL
};
In your application delegate source file (i.e. AppDelegate.m) you should see
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
If you created an NSDictionary with custom options, replace that line with
NSPersistentStoreCoordinator *coordinator = [EncryptedStore makeStoreWithOptions:options managedObjectModel:[self managedObjectModel]];
Otherwise, replace that line with:
NSPersistentStoreCoordinator *coordinator = [EncryptedStore makeStore:[self managedObjectModel]:@"SOME_PASSCODE"];
making sure to replace "SOME_PASSCODE" with a passcode of your own.
Also in the same file add an import for EncryptedStore.h:
#import "EncryptedStore.h"
If there are issues you can add -com.apple.CoreData.SQLDebug 1
to see all statements encryted-cored-data generates be logged.
Missing features and known bugs are maintained on the issue tracker
Below is a diagram showing the differences between NSSQLiteStore and EncryptedStore. Note that actual the SQLite calls are coupled fairly strongly with the layer wrapping it:
Below is the output of doing the unix strings command on a sample applications .sqlite file. As you can see, the default persistence store leaves all information in plaintext:
Copyright 2012 - 2014 The MITRE Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.