views:

314

answers:

4

Hello,

I have an MFC app which is wizard based. The App asks a user a variable number of questions which are then written to an INI file which is later encrypted when the user clicks Finish.

All the INI file parsers I have seen so far seen read or write to a physical file on Disk. I don't want to do this as the INI file contains confidential information. Instead I would like the INI file to be only based in memory and never written to disk in an un-encrypted form.

As the app allows users to go back and change answers, It occurred to me that I could use an in memory Database for this purpose but again I do not want anything written to Disk and don't want to ship a DB with my app if it can be avoided.

I have to use an INI file as it the file when un-encrypted will be processed by a 3rd party.

Any suggestions welcomed.

Thanks..

+3  A: 

I have an IniFile C++ class which allows you to work with Ini files in memory: http://www.lemonteam.com/downloads/inifile.h

It's a short, well documented single .h file. Sample usage:

IniFile if ( "myinifile.ini" );

if.SetString( "mykey", "myvalue" );


// Nothing gets actually written to disk until you call Flush(), Close() or the object is deleted
if.Flush();
if.Close();

You should be able to modify the Flush() method so that it applies some kind of encryption to the saved data.

Julio Gorgé
This looks good, I really needed it a couple of weeks ago!
Skilldrick
A: 

Sounds like a good application for a memory-mapped file, since you can control when your in-memory view gets flushed back to the file on disk.

Bob Moore
Yes, That what I had planed but I have to ensure that the INI file is never written to disk un-encrypted And I could see no way of doing that with a MMF.
Canacourse
A: 

Why would you need to have it in an ini file format if it is never stored to disk?

Why not just keep it in memory as a data structure and use your normal ini file methods to write it to disk when you want to.

paan
A: 

If you don't want to save into file, what is the point of using INI file then? INI API is bascially a property bag or key value pair based on disk file. If you don't want to use file, I suggest you use your own hash or dictionary data structure to store the key value parirs

adwords
The Ini File will be stored on disk but only when encrypted. Thanks..
Canacourse