Emir
Emir

Reputation: 23

does objectBox support data encryption?

I want to use objectbox in my project, I want to migrate from dbflow to objectBox, dbflow is supporting encryption, does objectBox support encryption?

Upvotes: 0

Views: 2349

Answers (3)

Codelicious
Codelicious

Reputation: 634

So in lieu of no official database encryption support from objectBox, we've gone the route of field encryption using the property converters.

We've implemented AES-256 encryption on String fields.

Thus far performance tests show the following:

  • No encryption, 1000 objects (13 fields / object) write ~ 2740ms
  • Encrypted, 1000 objects (13 fields, 6 encrypted) write ~ 6434ms
  • No encryption, 1000 objects (13 fields / object) read ~ 58ms
  • Encrypted, 1000 objects (13 fields, 6 encrypted) write ~ 70ms

Checkout this handy AES lib: https://github.com/scottyab/AESCrypt-Android

An example of the property converter class

class EncryptionConverter : PropertyConverter<String, String> {

    override fun convertToDatabaseValue(entityProperty: String): String {
        return AESUtil.encrypt("YOUR_SUPER_SECURE_KEY" , entityProperty)
    }

    override fun convertToEntityProperty(databaseValue: String?): String {
        return AESUtil.decrypt("YOUR_SUPER_SECURE_KEY" , databaseValue)
    }
}

Your field in entity class would look something like this

@Convert(converter = EncryptionConverter::class, dbType = String::class)
    var username : String = ""

Also remember, with field encryption you're giving up partial field lookup capability

Upvotes: 2

Uwe - ObjectBox
Uwe - ObjectBox

Reputation: 1327

There is no built-in support for encryption.

There is a feature request to support it. We welcome your suggestions. https://github.com/objectbox/objectbox-java/issues/8

Upvotes: 1

Ahmed Karam
Ahmed Karam

Reputation: 411

ObjectBox currently depends on Android security features, which includes sandboxing and encrypted storage (depends on the Android version). Additional efforts should be tracked in

this is the last state for this question from greenrobot

Upvotes: 0

Related Questions