Giter Site home page Giter Site logo

0 results returned about encrypted-core-data HOT 8 CLOSED

Gordiii avatar Gordiii commented on June 18, 2024
0 results returned

from encrypted-core-data.

Comments (8)

gavin-black avatar gavin-black commented on June 18, 2024

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.

Gordiii avatar Gordiii commented on June 18, 2024

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.

gavin-black avatar gavin-black commented on June 18, 2024

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.

Gordiii avatar Gordiii commented on June 18, 2024

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.

gavin-black avatar gavin-black commented on June 18, 2024

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.

Gordiii avatar Gordiii commented on June 18, 2024

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.

gavin-black avatar gavin-black commented on June 18, 2024

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.

Gordiii avatar Gordiii commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.