I have built a windows based form (VS2005 using VB.net 2.0) which is basically a questionnaire program - users fill in a series of text boxes and checkboxes and can then print off a report. The user can also save their progress to come back to at a later time; instead of going down the database route, I keep track of all the control values in a dataset, then read that that dataset into an XML file when they save. It's a simple case of reading the XML file back in and updating controls when they load it at a later date (the XML file is basically their saved document in their eyes).
This all works absolutely fine, except I've now been asked if I can encrypt the data that goes into the XML file - some of it is sensitive to the user. Any unscrupulous nosey parker who knew what they were doing could easily find the XML file and open it in notepad, for example. To be honest I'm currently struggling with this! I followed this guide:
http://www.devx.com/dotnet/Article/21564
Which does the trick nicely, the XML file is completely encrypted when saved, and I can decrypt it when it's loaded back in. However, this only works if the application (hence session) is kept open. If you save your progress, close the program, reopen it and try and load I get a "bad data" error, which I'm pretty sure is because a new tDES key is generated each time the program starts so obviously the decrypting doesn't work. I can't work out how to use the same key every time the program starts... it'd be absolutely fine if they key was embedded in the code, I'd be happy with that, but I can't work it out.
Does anyone have any ideas? Any other ways I should look at doing this?
TIA,
Tim
This all works absolutely fine, except I've now been asked if I can encrypt the data that goes into the XML file - some of it is sensitive to the user. Any unscrupulous nosey parker who knew what they were doing could easily find the XML file and open it in notepad, for example. To be honest I'm currently struggling with this! I followed this guide:
http://www.devx.com/dotnet/Article/21564
Which does the trick nicely, the XML file is completely encrypted when saved, and I can decrypt it when it's loaded back in. However, this only works if the application (hence session) is kept open. If you save your progress, close the program, reopen it and try and load I get a "bad data" error, which I'm pretty sure is because a new tDES key is generated each time the program starts so obviously the decrypting doesn't work. I can't work out how to use the same key every time the program starts... it'd be absolutely fine if they key was embedded in the code, I'd be happy with that, but I can't work it out.
Does anyone have any ideas? Any other ways I should look at doing this?
TIA,
Tim