We have an SQLCipher DB that we access from C++. The DB’s passphrase is a byte array which we pass to sqlite3_key()
and manage to open the DB successfully.
We need to access this DB from the Java side. Since the SQLCipher Java interface does not provide a method that accepts a byte array, we have to use the method that accepts a char array (SQLiteDatabase.openDatabase()). So, we have to convert our byte array to a char array. We couldn’t find a way to convert our passphrase (stored as a byte array) to a Java char array that can open our DB successfully (a char is 16 bits in Java).
One thing to note is that when converting the byte array to char array from the C++ side, not all characters are readable. So, we can’t use this string to open the DB via an external tool like “DB Browser for SQLite”.