Java Code Examples for net.sqlcipher.database.SQLiteDatabase#getBytes()
The following examples show how to use
net.sqlcipher.database.SQLiteDatabase#getBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PassphraseClearTest.java From cwac-saferoom with Apache License 2.0 | 6 votes |
@Test public void byteArrayCleared() throws IOException { char[] charArray = PASSPHRASE.toCharArray(); byte[] byteArray = SQLiteDatabase.getBytes(charArray); SafeHelperFactory factory=new SafeHelperFactory(byteArray); SupportSQLiteOpenHelper helper= factory.create(InstrumentationRegistry.getTargetContext(), DB_NAME, new Callback(1)); SupportSQLiteDatabase db=helper.getWritableDatabase(); helper.close(); byte[] expected = new byte[byteArray.length]; for (int i=0;i<expected.length;i++) { expected[i]=(byte)0; } assertArrayEquals(expected, byteArray); }
Example 2
Source File: KriptonSQLCipherHelperFactory.java From kripton with Apache License 2.0 | 3 votes |
/** * Standard constructor. * * Note that the passphrase supplied here will be filled in with zeros after * the database is opened. Ideally, you should not create additional copies * of this passphrase, particularly as String objects. * * If you are using an EditText to collect the passphrase from the user, * call getText() on the EditText, and pass that Editable to the * SafeHelperFactory.fromUser() factory method. * * @param passphrase * user-supplied passphrase to use for the database * @param postKeySql * optional callback to be called after database has been "keyed" * but before any database access is performed */ public KriptonSQLCipherHelperFactory(char[] passphrase, String postKeySql) { this(SQLiteDatabase.getBytes(passphrase), postKeySql); if (options.clearPassphrase) { clearPassphrase(passphrase); } }
Example 3
Source File: KriptonSQLCipherHelperFactory.java From kripton with Apache License 2.0 | 3 votes |
/** * Standard constructor. * * Note that the passphrase supplied here will be filled in with zeros after * the database is opened. Ideally, you should not create additional copies * of this passphrase, particularly as String objects. * * If you are using an EditText to collect the passphrase from the user, * call getText() on the EditText, and pass that Editable to the * SafeHelperFactory.fromUser() factory method. * * @param passphrase * user-supplied passphrase to use for the database * @param options * options for pre-key, post-key SQL */ public KriptonSQLCipherHelperFactory(char[] passphrase, Options options) { this(SQLiteDatabase.getBytes(passphrase), options); if (options.clearPassphrase) { clearPassphrase(passphrase); } }
Example 4
Source File: SafeHelperFactory.java From cwac-saferoom with Apache License 2.0 | 2 votes |
/** * Standard constructor. * * Note that the passphrase supplied here will be filled in with zeros after * the database is opened. Ideally, you should not create additional copies * of this passphrase, particularly as String objects. * * If you are using an EditText to collect the passphrase from the user, * call getText() on the EditText, and pass that Editable to the * SafeHelperFactory.fromUser() factory method. * * @param passphrase user-supplied passphrase to use for the database * @param postKeySql optional callback to be called after database has been * "keyed" but before any database access is performed */ public SafeHelperFactory(char[] passphrase, String postKeySql) { this(SQLiteDatabase.getBytes(passphrase), postKeySql); if (options.clearPassphrase) { clearPassphrase(passphrase); } }
Example 5
Source File: SafeHelperFactory.java From cwac-saferoom with Apache License 2.0 | 2 votes |
/** * Standard constructor. * * Note that the passphrase supplied here will be filled in with zeros after * the database is opened. Ideally, you should not create additional copies * of this passphrase, particularly as String objects. * * If you are using an EditText to collect the passphrase from the user, * call getText() on the EditText, and pass that Editable to the * SafeHelperFactory.fromUser() factory method. * * @param passphrase user-supplied passphrase to use for the database * @param options options for pre-key, post-key SQL */ public SafeHelperFactory(char[] passphrase, Options options) { this(SQLiteDatabase.getBytes(passphrase), options); if (options.clearPassphrase) { clearPassphrase(passphrase); } }