Comments (8)
Maybe I'm missing something, but how are you attempting to run sql queries? Encrypted Core Data uses standard core data calls to store and retrieve values. There shouldn't be any raw select statements you would be using on your end.
If you are just trying to look at the sqlite file using the sqlite3 CLI, then you need to make sure you have a version that supports ssl(Compile sqlcipher by hand and it should produce the proper executable to use) and set the pragma by hand (PRAGMA key=whatever).
from encrypted-core-data.
Hello,
I'm not using any SQL queries directly but using the following core data calls in ViewDidLoad
....
AppDelegate* appDelegate = [AppDelegate sharedAppDelegate];
NSManagedObjectContext* moc = appDelegate.managedObjectContext;
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@Profile" inManagedObjectContext:moc];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entityDescription];
profilesArray = [moc executeFetchRequest:fetchRequest error:nil];
NSLog(@"fetch count: %d", [profilesArray count]);
From the CLI, I am able to get results using sqlcipher:
$ ./sqlcipher encrypted.db
sqlite> PRAGMA KEY='myTestKey';
sqlite> SELECT COUNT(*) FROM ZPROFILE
1066
The SQL queries I listed in my last post was debug statements from the Xcode output window.
from encrypted-core-data.
Hmmm, very odd. Sounds like it is storing it correctly, and your code seems fine. No errors getting buried in the console when you run your fetch request? Also if you run "strings encrypted.db" does it produce complete garbage? If it produces readable results something is wrong with the initial setup.
from encrypted-core-data.
No errors getting buried in the console when you run your fetch request?
Nope
Also if you run "strings encrypted.db" does it produce complete garbage?
Yes, produce garbage such as:
84aw
??-B'?
8G;M1
+EXr6`
Sb-KS
I've isolated this into an independent small Xcode project. Would you like to take a look to see if you can spot anything? If so, here's the link:
https://dl.dropboxusercontent.com/u/1846743/TestSQLCipher.tar.gz
The sqlcipher.xcodeproj and openssl-xcode/openssl.xcodeproj references in the Xcode project for setting up "SQLCipher for iOS (http://sqlcipher.net/ios-tutorial/), were taken from https://github.com/sqlcipher/SQLCipherSpeed.git.
from encrypted-core-data.
Thanks for the sample code, was able to get it running and it prints back 0 results as you described. Will try to track down where the issue is.
from encrypted-core-data.
Cool. Just to note, from the command line, if you run:
./sqlcipher
sqlite> PRAGMA KEY='testkey';
sqlite> SELECT COUNT(*) FROM ZEATPROFILE
you should get 1066
from encrypted-core-data.
Hmm for whatever reason I can't get PreloadUncover-Encrypted to decrypt. Can get all other encrypted dbs, including TestSQLCipher.sql, decrypted and read from them on command line. Any chance the key is wrong?
But actually I think the issue is where did PreloadUncover come from? You said it works with core-data, so did you take a working sqlite file generated from core-data, encrypt it by hand, and then use it? If so, encrypted-core-data isn't smart enough to automagically do the translation. Under the hood we are making our own sqlite tables and structures that are different to the existing core-data ones (Instead of reverse engineering Apple's layout, which in hindsight may have been smarter).
If that's the issue the work around would be to regenerate your structures programmatically. You can load up two controllers simultaneously, one for core-data and one for encrypted-core-data and should be able to fetch entities from one and save to the other. Not at all elegant, and there really should be migration code to ease the task, but should work.
from encrypted-core-data.
did you take a working sqlite file generated from core-data, encrypt it by hand, and then use it?
Yes, spot on. I've got it to work now! Thanks very much for your prompt responses.
Although, I'm using SQLCipher version 3.7.17 as opposed to 3.8.0.2 which is in the Air:SQLCipherSpeed github project. The later was causing some issue, which I think I'm not going to put any effort into now.
from encrypted-core-data.
Related Issues (20)
- ARC Semantic Issue Multiple methods named 'objectID' found with mismatched result, parameter type or attributes
- Using Encrypted CoreData in App Extension
- Unable to change password
- unable to initialize class object to change password HOT 1
- Fetch return nil data HOT 1
- missing support for batch requests (NSBatchDeleteRequest, NSBatchUpdateRequest) HOT 1
- Doesn't encrypt the .sqlite file and extra "ecd" tables doesn't have any records.
- Migration Old unencrypted Core database to Encrypted Core Data base(using SQLCipher).
- Migration Old unencrypted Core database to Encrypted Core Data base. HOT 2
- XCode 12 build error HOT 1
- Migrating SQLCipher version from 3.x to 4.x in Encrypted Core Data HOT 1
- How to implement Encrypted Core Data in Existing project with Swift 5.3.2 HOT 1
- NSFetchRequest returnsObjectsAsFaults doesn't work HOT 1
- Is this project no longer being maintained? HOT 3
- 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release HOT 2
- Very small subset of users randomly getting EncryptedStoreErrorIncorrectPasscode error
- issue with Lightweight migration Coredata
- iOS CoreData- Tracking persistent transaction history
- Swift no such moduble EncrytedCoreData
- Default DB Storage location
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from encrypted-core-data.