I have MS C# and MS SQL 2008 database project. It can capture employees' records with pictures of more than 1000 records.

Presently, I'm able to capture say 150 records on PC1 using my installed C# application, save the records into XML or CSV file format. My friends are able to continue registration or entering (i.e from 151 to 1000) after restoring or uploading the information contained in that XML or CSV using another copy of my C# application installed on their laptops at another location.

How can the content of the file be encrypted or hidden from users viewing its content except for my C# app reading or writing to this said backup files.?

  • Please, the basic aim here is to learn from those who are experienced or had handle similar challenges before. Please direct us to the right channel instead of complaining -- gnat
    – Gentlesule
    Jul 3 '14 at 4:31
  • 1
    Why was my question closed as too broad? There are too many possible answers to this question. It will depend heavily on what server technology you use for file storage. Then there is the matter of portable encryption and/or tamper awareness. And finally, your requirements say that you need to be able to import the data and images on any machine. You will probably be able to get better answers by limiting the question to one subject. Jul 3 '14 at 4:41
  • 7
    If you want your question not to be closed, take enough time for writing a detailed description of your problem. What kind of database/version, rough sketch of your db schema, how many records of what size? How did you create your CSV or XML files, and how large do they get (and what do you consider as "too large")? And why is a standard db backup as recommended by microsoft (msdn.microsoft.com/library/ms187510.aspx) not enough? But be quick, otherwise I expect your question beeing closed soon.
    – Doc Brown
    Jul 3 '14 at 6:03
  • 1
    @gnat: I think the general problem is clear now, and to answer it it is actually not so important wants to prevent changes to the file in general, or to allow changes in specficic cases. I vote to reopen.
    – Doc Brown
    Jul 3 '14 at 9:45
  • 2
    I guess what you are looking for is just a Zip library with encryption. See, for example, here dotnetzip.codeplex.com
    – Doc Brown
    Jul 3 '14 at 9:49

To answer your first question, that's simple, encrypt the file. Use a symmetric key that is shared between the application you use and that your friends use. Only someone with the key can read the data. Where you store the key depends on how paranoid you are.

The simplest is simply to hardcode the key into the application. If you're concerned about hackers accessing it however, that would be nowhere near secure enough.

To answer your second question, there's two components to what you're storing from what I understand of your question: a picture, and data. The picture you should store as binary, probably PNG format would be the best option. The data I'd store as JSON. You's want some way of bundling the two sets of data to each other, and the whole set of data into a container. Plus some compression for the JSON.

So that screams for a ZIP file, and conveniently, you can also encrypt ZIP files.

So, I'd create two files, with the same name, but different extension for each record (e.g. Record1.json and Record1.png), and place them all into an encrypted ZIP file using SharpZipLib or similar (https://github.com/icsharpcode/SharpZipLib/wiki/Zip-Samples).

You didn't really indicate how many records we're talking here, if it's thousands you might want to create a directory structure using a search tree for the record index. So, if for example you search for records by the surname, you'd use the first letter or two of the surname as the first folder name, to speed access and reduce the time to iterate all the records.

Not the answer you're looking for? Browse other questions tagged or ask your own question.