What is the best way to store data in the app, then copy it to a computer in a secure way?

My app is simply a data entry app, in which user can type in information like name, dob, address etc. 

The app needs to be able to run without an internet.

Therefore I simply used a Sqlite3 to store data in the app. In the end of the day, I connect to the internet and email the sqlite3.db file to my email address.

There is a problem here:

when I email the .db file, I have to use a Pop-up email client. In which user can see the .db file. So anyone can download it or email it to another person in the pop up. This is not very secure, because the sqlite3.db file can’t be encrypted in Corona.

Is there any better ways to do this?

You can either encrypt the data within the .db file, encrypting each field before you store it and unencrypting it when you read it into the app.

Or you could actually encrypt the whole file. You read it in as text, encrypt the text, then save that file and send it via e-mail. At the other end you read the file in as text, decrypt and save the file as a .db file.

thanks for your reply. I really want to find an example of the latter. How can I read in a .db into a text and encrypt it? Also, how can I do the reverse?

You can use the OpenSSL plugin to encrypt the database, then use the mime library’s b64 (base 64) to encode it into ASCII transmittable text. Then when you receive it, run it through a base 64 decoder (will depend on what platform you’re running on) and you may need an app that knows the OpenSSL encryption methods to decrypt it back into an SQLite database.

But I would seriouslly reconsider this process. You have to have Internet available to email. Why not have your app check periodically if it has Internet and then transmit updated records to a web services and keep the user’s sending of emails out of it. If you use an HTTPS endpoint for  your web service, you don’t have to encrypt the data yourself since HTTPS encrypts it for you.

Thanks Rob. I will probably go for the latter approach. The only thing is that we will need a server…

You can either encrypt the data within the .db file, encrypting each field before you store it and unencrypting it when you read it into the app.

Or you could actually encrypt the whole file. You read it in as text, encrypt the text, then save that file and send it via e-mail. At the other end you read the file in as text, decrypt and save the file as a .db file.

thanks for your reply. I really want to find an example of the latter. How can I read in a .db into a text and encrypt it? Also, how can I do the reverse?

You can use the OpenSSL plugin to encrypt the database, then use the mime library’s b64 (base 64) to encode it into ASCII transmittable text. Then when you receive it, run it through a base 64 decoder (will depend on what platform you’re running on) and you may need an app that knows the OpenSSL encryption methods to decrypt it back into an SQLite database.

But I would seriouslly reconsider this process. You have to have Internet available to email. Why not have your app check periodically if it has Internet and then transmit updated records to a web services and keep the user’s sending of emails out of it. If you use an HTTPS endpoint for  your web service, you don’t have to encrypt the data yourself since HTTPS encrypts it for you.

Thanks Rob. I will probably go for the latter approach. The only thing is that we will need a server…