using sqlite_key programmatically in C#

680 views
Skip to first unread message

brian...@leanderisd.org

unread,
Oct 17, 2013, 6:11:15 PM10/17/13
to sqlc...@googlegroups.com

I have the commercial copy of SqlCipher.dll for MonoTouch and Android.   I have included a reference to sqlcipher.dll in my project and I can create a connection and open my encrypted database in my C# code.

I can use code like this:

        private SqliteConnection GetConnection(String databaseName, String password)
        {
            var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), databaseName);
            return new SqliteConnection(String.Format("Data Source={0};Password={1}", databasePath, password));
        }

But I cannot use code like this which is referenced here http://sqlcipher.net/sqlcipher-api/#key:

sqlite3_key(database, "test123", 7);
	if (sqlite3_exec(database, "SELECT count(*) FROM sqlite_master;", NULL, NULL, NULL) == SQLITE_OK) {
		// key is correct.
	} else {
                // key is incorrect
        }


sqlite3_key does not seem to be available

I would like to use sqlite3_key within the Xamarin project in C# code. Am I missing a reference call ?

Any help would be greatly appreciated


Nick Parker

unread,
Oct 18, 2013, 10:29:36 AM10/18/13
to sqlc...@googlegroups.com
Hi Brian,

sqlite3_key is the C API and thus is not directly exposed in the
SQLCipher for Xamarin client library. When you build a command object
from the connection, you can issue a PRAGMA key [1] or rekey [2] command
from the client library that will subsequently call the appropriate C
function.

1. http://sqlcipher.net/sqlcipher-api/#key
2. http://sqlcipher.net/sqlcipher-api/#rekey
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "SQLCipher Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sqlcipher+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
Nick Parker

signature.asc
Reply all
Reply to author
Forward
0 new messages