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[]
