I am planing to encrypt some preference files in my program, so that the users can not read them. What method or what commands from the Cipher library can you guys advise me?
Greetings,
es_91.
encrypting pref files
Re: encrypting pref files
If the sole purpose is to hide the information from the user, just use a simple
byte rotation or Base64 encoding. Of course advanced users can easily
decode this and change the settings file.
Actually encrypting the content requires a key that needs to be stored in "plain text",
since the application needs to be able to decrypt it. That means if the user can get
a hold of the key, he can decrypt the content.
What I'm trying to say is, it doesn't make sense to do that as it can be worked around
quite easily and offers no real protection.
byte rotation or Base64 encoding. Of course advanced users can easily
decode this and change the settings file.
Actually encrypting the content requires a key that needs to be stored in "plain text",
since the application needs to be able to decrypt it. That means if the user can get
a hold of the key, he can decrypt the content.
What I'm trying to say is, it doesn't make sense to do that as it can be worked around
quite easily and offers no real protection.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: encrypting pref files
I understand. I was not looking for complete protection, just a little chicane for the user. I think I will use bit rotation. Thanks.

Re: encrypting pref files
Just use CompressMemory() before saving to file.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: encrypting pref files
The problem is you can't do OpenPreferences from memory, a file is needed.
In this way, after decrypt, you need to save the file in plain text somewhere, and then delete it when used, that's not a good encryption system.
Another way is encrypt only the values of each of the preference lines:
In this way, after decrypt, you need to save the file in plain text somewhere, and then delete it when used, that's not a good encryption system.
Another way is encrypt only the values of each of the preference lines:
Code: Select all
[*ALLUSR]
TCUSR=nUNUgy87u9i
TCPWD=zWsW%1523Xe
Re: encrypting pref files
If you want to hide the "name" of the preference, just use an array, and a loop...
(not checked for syntax)
for loopcounter = 0 to #PrefCount
writepreferenceinteger(file, "Pref"+str(loopcounter), prefarray(loopcounter))
next
(not checked for syntax)
for loopcounter = 0 to #PrefCount
writepreferenceinteger(file, "Pref"+str(loopcounter), prefarray(loopcounter))
next