I have a table with messages in a chat app and i want to use TripleDes encryption in the column body of the table in my Room Database. What i do now is that whenever i has an array of new messages i loop through them and change the .body field to TripleDes.encrypt(body)
// TripleDes encryption to inserted messages
messageDtoList.forEach {
if (it.body.isNotEmpty())
it.body = TripleDesEncrypt.encrypt(it.body, Params.TRIPLE_DES_KEY)
}
AppDatabase.invoke(MyApplication.instance).messageDao().insert(messageDtoList)
I wanted to know if there is a better and more formal way to do this