简体   繁体   中英

.NET - Best way to store encrypted offline data in Desktop Application

I couldn't find proper topic so I'm creating this question. I'm building an Desktop application that is running on data from MS SQL Database. Most of the data there is updated once a week/month, and most of the tables are read-only to end user. I figured, there is no need for the user to work directly on SQL Database online and in order to speed up the performance, I want the app to download necessary data from SQL Database on start, and then use localy saved data + in case of server outage user should be able to load app using latest saved data.

The thing is, data needs to be encrypted and secured from unauthorised use. I used to have SQLite database, but running on two databases doesn't feel efficient.

What solution would you suggest?

The problem with encrypting is:

1 - you need to decrypt in order to use the data in your application, which will have a performance impact.

2 - if you can decrypt, so can someone who has obtained the data illegally so it's not really that secure.

If you did want to go down this route, you could read in the data from the DB, decrypt and then cache it, which will speed the application.

The cache could last for several days based on the fact you said it only gets updated every few weeks/months and minimise DB calls

I am not sure your proposal is a great solution.

You have data that a user should not have full access to; so you want it encrypted.

The easiest way to limit access is to not give the user access at all; for example by putting a server in front of it. The server can only talk to the database and the database is secure and encrypted etc.. now you don't need client side encryption (which can always be broken if a hacker has enough time and money). You just secure your server and expose some API's and boom, you are secure.

But let's find out a bit more about your data. The client of course needs to view the data in the app, but isn't allowed to have access to the database when running locally. Why do you have data in the local database that the user isn't allowed to see in this case? This sounds like a security issue where a user might have (private) data of your company or other users on their pc, which you do not want, ever. So let's say we only store data on your pc that the user can see in the app anyway. Security is better now!

Now to solve the problem of performance. How much of a problem is it? You could implement caching in the server and client, depending on how performance problems you have. When the server only returns data that the client is allowed to see, you could cache it in the client and also on the server.

If the client already has data cached and doesn't need to retrieve new data (when is this?), Then it doesn'y need to talk to the API. and if the client doesn't have data or has outdated data, the API checks if it has the new data cached and returns it immediately if so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM