Hi Stephen
thanks for your help. I removed the source code folders of sqlcipher
and openssl, re-downloaded them and followed the tutorial on using
them for my own project (
http://sqlcipher.net/documentation/ios).
Everything compiled fine, but the libraries were still red. So I open
both the openssl and sqlcipher xocde projects, and compiled. The
encryption-enabled sqlite3 was not in the sqlcipher folder, so I went
to the terminal and used the command you suggested above, i.e.
nemesis@Ioanniss-MacBook:~/Documents/source/sqlcipher$ ./configure --
prefix=/Users/nemesis/Documents/source/sqlcipher --enable-
tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
nemesis@Ioanniss-MacBook:~/Documents/source/sqlcipher$ make
nemesis@Ioanniss-MacBook:~/Documents/source/sqlcipher$ make install
Here is the output of make install
*** start of terminal output ***
/usr/bin/install -c -d /Users/nemesis/Documents/source/sqlcipher/lib
./libtool --mode=install /usr/bin/install -c
libsqlite3.la /Users/
nemesis/Documents/source/sqlcipher/lib
libtool: install: /usr/bin/install -c .libs/libsqlite3.0.dylib /Users/
nemesis/Documents/source/sqlcipher/lib/libsqlite3.0.dylib
libtool: install: (cd /Users/nemesis/Documents/source/sqlcipher/lib &&
{ ln -s -f libsqlite3.0.dylib libsqlite3.dylib || { rm -f
libsqlite3.dylib && ln -s libsqlite3.0.dylib libsqlite3.dylib; }; })
libtool: install: /usr/bin/install -c .libs/libsqlite3.lai /Users/
nemesis/Documents/source/sqlcipher/lib/
libsqlite3.la
libtool: install: /usr/bin/install -c .libs/libsqlite3.a /Users/
nemesis/Documents/source/sqlcipher/lib/libsqlite3.a
libtool: install: chmod 644 /Users/nemesis/Documents/source/sqlcipher/
lib/libsqlite3.a
libtool: install: ranlib /Users/nemesis/Documents/source/sqlcipher/lib/
libsqlite3.a
----------------------------------------------------------------------
Libraries have been installed in:
/Users/nemesis/Documents/source/sqlcipher/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
echo 'package ifneeded sqlite3 3.7.2 [list load /System/Library/
Frameworks/Tcl.framework/Versions/8.5/Resources/Scripts/sqlite3/
libtclsqlite3.so sqlite3]' > pkgIndex.tcl
/usr/bin/install -c -d /System/Library/Frameworks/Tcl.framework/
Versions/8.5/Resources/Scripts/sqlite3
install: mkdir /System/Library/Frameworks/Tcl.framework/Versions/8.5/
Resources/Scripts/sqlite3: Permission denied
make: *** [tcl_install] Error 71
*** end of terminal output ***
I wouldn't post the output if I didn't see an error message. However,
I went to my sqlcipher path (/Users/nemesis/Documents/source/
sqlcipher) and followed the attach instructions (
http://sqlcipher.net/
documentation/api#attach), and... VOILA, my database was encrypted!!!
But I tried to use it from my xcode project like this
*** Obj-C code ***
...
#import <sqlite3.h>
...
- (void)viewDidLoad {
[super viewDidLoad];
sqlite3 *db;
const char *dbFile = [@"/Users/nemesis/Desktop/encrypted.db"
UTF8String];
if (sqlite3_open(dbFile, &db) == SQLITE_OK) {
//sqlite3_exec(db, "PRAGMA key = 'BIGsecret'", NULL, NULL, NULL);
//if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM
sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
// // password is correct, or, database has been initialized
// } else {
// // incorrect password!
// }
}
}
*** end of Obj-C code ***
but I get the following error:
*** Xcode build errors ***
Ld "/Users/nemesis/Documents/App Development/xcode-builds/Debug-
iphonesimulator/Crypto.app/Crypto" normal i386
cd /Users/nemesis/Desktop/Crypto
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/
usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/
gcc-4.2 -arch i386 -isysroot /Developer/Platforms/
iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk "-L/
Users/nemesis/Documents/App Development/xcode-builds/Debug-
iphonesimulator" "-F/Users/nemesis/Documents/App Development/xcode-
builds/Debug-iphonesimulator" -filelist "/Users/nemesis/Documents/App
Development/xcode-builds/Crypto.build/Debug-iphonesimulator/
Crypto.build/Objects-normal/i386/Crypto.LinkFileList" -mmacosx-version-
min=10.6 -Xlinker -objc_abi_version -Xlinker 2 "/Users/nemesis/
Documents/App Development/xcode-builds/Debug-iphonesimulator/
libsqlcipher.a" "/Users/nemesis/Documents/App Development/xcode-builds/
Debug-iphonesimulator/libcrypto.a" -framework Foundation -framework
UIKit -framework CoreGraphics -o "/Users/nemesis/Documents/App
Development/xcode-builds/Debug-iphonesimulator/Crypto.app/Crypto"
Undefined symbols:
"_bn_sub_part_words", referenced from:
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
*** end of Xcode build errors ***
Any ideas? I also tried this alternative
*** code ***
#import <sqlite3.h>
...
sqlite3 *db;
const char *dbFile = [@"/path/to/database" UTF8String];
if (sqlite3_open(dbFile, &db) == SQLITE_OK) {
const char* key = [@"BIGSecret" UTF8String];
sqlite3_key(db, key, strlen(key));
if (sqlite3_exec(db, (const char*) "SELECT count(*) FROM
sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
// password is correct, or, database has been initialized
} else {
// incorrect password!
}
}
*** end code ***
and got these build results
*** build errors ***
/Users/nemesis/Desktop/Crypto/Classes/CryptoViewController.m:41:0 /
Users/nemesis/Desktop/Crypto/Classes/CryptoViewController.m:41:
warning: implicit declaration of function 'sqlite3_key'
"_bn_sub_part_words", referenced from:
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
_bn_mul_part_recursive in libcrypto.a(bn_mul.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
*** end build errors ***
Thanks for your ongoing support. Best,
John