Given the Entity:
@Entity(tableName = "otp_tokens")
data class DBEntity (
@PrimaryKey(autoGenerate = true)
val id: Long,
val data: String,
val encryptionType: EncryptionType
)
EncryptionType:
enum class EncryptionType {
PLAIN_TEXT,
ENCRYPTED
}
I want to use a @TypeConverter to encrypt/decrypt the data String field when accessing the database, based on the value of the encryptionType field value. So for example if encryptionType == PLAIN_TEXT the TypeConverter should not do anything with the String value, but if encryptionType == ENCRPYTED it should encrypt/decrypt the data field.
When I write a TypeConverter for the data field I only get the String value of data in the encrypt/decrypt methods of the Converter and have no access to the encryptionType field, so how can I implement this?
