47 lines
1.1 KiB
Plaintext
47 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/[SQLCipher]
|
|
|
|
[source,java]
|
|
----
|
|
String key = "gb09ym9ydoolp3w886d0tciczj6ve9kszqd65u7d126040gwy86xqimjpuuc788g";
|
|
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase("test.db", key, null); // Noncompliant
|
|
----
|
|
|
|
https://github.com/realm/realm-java/[Realm]
|
|
|
|
[source,java]
|
|
----
|
|
String key = "gb09ym9ydoolp3w886d0tciczj6ve9kszqd65u7d126040gwy86xqimjpuuc788g";
|
|
RealmConfiguration config = new RealmConfiguration.Builder();
|
|
.encryptionKey(key.toByteArray()) // Noncompliant
|
|
.build();
|
|
Realm realm = Realm.getInstance(config);
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/[SQLCipher]
|
|
|
|
[source,java]
|
|
----
|
|
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase("test.db", getKey(), null);
|
|
----
|
|
|
|
https://github.com/realm/realm-java/[Realm]
|
|
|
|
[source,java]
|
|
----
|
|
RealmConfiguration config = new RealmConfiguration.Builder()
|
|
.encryptionKey(getKey())
|
|
.build();
|
|
Realm realm = Realm.getInstance(config);
|
|
----
|
|
|
|
include::../see.adoc[]
|