tags:

views:

296

answers:

3

Hi

I encrypted some text and put it in a INI file. Then I used getprivateprofilestring() to retrieve the value but some of the end characters are missing. I suspect it may be a new line character causing it to be incomplete. Writing to the INI file is OK. Opening the INI file and looking at the sections and keys - everything is in order. Its just the retrieving part that causes the bug.

Please any help would be appreciated.

Thanks Eddie

A: 

WritePrivateProfileStringW writes files in the active ANSI codepage by default; WritePrivateProfileStringA will always write ANSI.

To achieve the best results, follow the directions here and use GetPrivateProfileStringW when reading the data back

rpetrich
+1  A: 

First off when encrypting strings, make sure that they are converted to Base64 before dumping them into the INI file.

Most likely, the encrypted string created an ascii character which is not handled very well by the INI related APIs.

AngryHacker
A: 

It's more than likely that the encryption is injecting a NULL character into the stream you are writing. GetPrivateProfileString will read a string till it finds a NULL character.

So I agree with Angry Hacker, convert to Base64 or some other friendly human readable encoding and you won't have any problems.

Bigtoe