0

I'm trying to follow this tutorial: http://sqlcipher.net/ios-tutorial/

I create a database called "sqlcipher.db" then I recreate this

When I execute this code:

- (void)viewDidLoad
{
 [super viewDidLoad];
 // Do any additional setup after loading the view, typically from a nib.
 NSString *databasePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] 
 stringByAppendingPathComponent: @"encrypted.db"];
 sqlite3 *db;
 if (sqlite3_open([databasePath UTF8String], &db) == SQLITE_OK) {
 const char* key = [@"secret" UTF8String];
 int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);
 sqlite3_key(db, key, strlen(key));
 if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM t1;", NULL, NULL, NULL) == SQLITE_OK) {
 // password is correct, or, database has been initialized
 NSLog(@"Hello 1");
 } else {
 // incorrect password!
 NSLog(@"Hello 2");
 }
 sqlite3_close(db);
 } else {
 NSLog(@"Hello 3");
 }
}

It allways outs "Hello 2".

When I try to reproduce the steps to crate an encrypted db described here http://zetetic.net/blog/2009/12/29/how-to-encrypt-a-plaintext-sqlite-database-to-use-sqlcipher.html#disqus_thread I can't get it encrypted, I believe that it is beacause I am using sqlite3 mac command.

So I saw in the comments that S Lombardo says that I have to compile a command line sqlcipher executable but the link doesn't works.

How should I encrypt my database to use it with SQLcipher?

Did anyone have success using sqlicipher in iOS?

asked May 14, 2012 at 17:09

1 Answer 1

1

After one hour Googling i've found how to compile sqlcipher command line for OSX:

I hope this could help somebody.

https://groups.google.com/forum/#!msg/sqlcipher/bd1R13RpZHQ/SEPK8YrRt1gJ

answered May 14, 2012 at 18:03
Sign up to request clarification or add additional context in comments.

1 Comment

This is also documented on the introduction to SQLCipher page: sqlcipher.net/introduction

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.