Page 1 of 1

encrypting pref files

Posted: Tue May 14, 2013 9:17 am
by es_91
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.

Re: encrypting pref files

Posted: Tue May 14, 2013 10:43 am
by Shield
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.

Re: encrypting pref files

Posted: Tue May 14, 2013 11:23 am
by es_91
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

Posted: Tue May 14, 2013 4:27 pm
by skywalk
Just use CompressMemory() before saving to file.

Re: encrypting pref files

Posted: Wed May 15, 2013 8:11 am
by graves
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:

Code: Select all

[*ALLUSR]
TCUSR=nUNUgy87u9i
TCPWD=zWsW%1523Xe

Re: encrypting pref files

Posted: Sun May 19, 2013 6:51 pm
by Tenaja
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