@@ -68,17 +68,27 @@ implementation "androidx.sqlite:sqlite:2.0.1"
68
68
SQLCipher for Android has a ` SupportFactory ` class in the ` net.sqlcipher.database ` package
69
69
that can be used to configure Room to use SQLCipher for Android.
70
70
71
- There are two ` SupportFactory ` constructors:
71
+ There are three ` SupportFactory ` constructors:
72
72
73
- - Both take a ` byte[] ` to use as the passphrase (if you have a ` char[] ` , use
74
- ` SQLiteDatabase.getBytes() ` to get a suitable ` byte[] ` to use)
73
+ - ` SupportFactory(byte[] passphrase) `
74
+ - ` SupportFactory(byte[] passphrase, SQLiteDatabaseHook hook) `
75
+ - ` SupportFactory(byte[] passphrase, SQLiteDatabaseHook hook, boolean clearPassphrase) `
75
76
76
- - One constructor has a second parameter: a ` SQLiteDatabaseHook ` that you can use
77
- for executing SQL statements before or after the passphrase is used to decrypt
78
- the database
77
+ All three take a ` byte[] ` to use as the passphrase (if you have a ` char[] ` , use
78
+ ` SQLiteDatabase.getBytes() ` to get a suitable ` byte[] ` to use).
79
79
80
- - One constructor option includes a boolean parameter to opt out of the clearing
81
- the passphrase used to access the SQLCipher database.
80
+ Two offer a ` SQLiteDatabaseHook ` parameter that you can use
81
+ for executing SQL statements before or after the passphrase is used to decrypt
82
+ the database.
83
+
84
+ The three-parameter constructor also offers ` clearPassphrase ` , which defaults
85
+ to ` true ` in the other two constructors. If ` clearPassphrase ` is set to ` true ` ,
86
+ this will zero out the bytes of the ` byte[] ` after we open the database. This
87
+ is safest from a security standpoint, but it does mean that the ` SupportFactory `
88
+ instance is a single-use object. Attempting to reuse the ` SupportFactory `
89
+ instance later will result in being unable to open the database, because the
90
+ passphrase will be wrong. If you think that you might need to reuse the
91
+ ` SupportFactory ` instance, pass ` false ` for ` clearPassphrase ` .
82
92
83
93
Then, pass your ` SupportFactory ` to ` openHelperFactory() ` on your ` RoomDatabase.Builder ` :
84
94
0 commit comments