encrypting pref files

Everything else that doesn't fall into one of the other PB categories.
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

encrypting pref files

Post 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.
:mrgreen:
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: encrypting pref files

Post 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.
Image
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
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: encrypting pref files

Post 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.
:mrgreen:
User avatar
skywalk
Addict
Addict
Posts: 4219
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: encrypting pref files

Post by skywalk »

Just use CompressMemory() before saving to file.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Re: encrypting pref files

Post 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
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: encrypting pref files

Post 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
Post Reply