How to save encrypted data securely in Android?

1

I am making a chat application and I want to save the conversations of users on their phones to be able to access them when it is offline, but I do not know how to save those conversations, I understand that they can be saved in SharedPreferences, files text (.txt), .DAT files, sqLite, etc ... but I do not know which is the most recommended or which of these use the main instantaneous messaging apps like Whatsapp, Telegram or Facebook Messenger and I want the data to be saved encrypted so that they can not be accessed from external apps

    
asked by Sneyder Angulo 03.09.2016 в 20:37
source

2 answers

0

If the user's device is root, it does not matter where you store the information because the user will be able to access the database files or those of Shared preferences or any files that are stored in the folders of the App.

Encryption is fundamental to the task you want to do to keep conversations private. I would recommend using the Database for the storage of conversations, since it will be easier to access the information you want and can store a large volume of data.

WhattsApp for example, if I'm wrong, use Database, which is backed up every day and these copies are encrypted. If you enter with a file manager you can see inside the WhatsApp folder a folder called Databases in which you can see the BD with the name msgstore.db.crypt12 and the backups named msgstore-año-mes-dia.1. db.crypt12. Telegram and Facebook Messenger I have not investigated how they manage this.

I hope it helps you.

    
answered by 08.09.2016 / 11:06
source
0

The best thing is that you encrypt (and decrypt when reading), it can be with an encryption algorithm per key, I recommend that you make your own algorithm (look for bit operators for this) and that you encrypt each data of the conversation (character , value, etc) and that you encrypt the file (byte by byte) for a more effective encryption and the encryption key can be generated by your server

    
answered by 19.10.2016 в 22:55