Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Encoder/Decoder w/ Numbers?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tlivingston




PostPosted: Mon Nov 25, 2002 11:20 pm   Post subject: Encoder/Decoder w/ Numbers?

Heres the scenario.

Im makin that rpg i talked about earlier and I have an option where the player can write to a file to "save" his/her game. The problem is that it saves as a tesxt file which can be EASILY hacked and so i want some sort of thing to encode the variables being saved (this is to ensure that when i make a stand alone program ppl will not cheat).

The thing is, i've got strings figured out (quite easy to do) but how could i do it w/ numbers other than adding a certain number to the value?

Any help appreciated.

Ted
Sponsor
Sponsor
Sponsor
sponsor
FizixMan




PostPosted: Tue Nov 26, 2002 1:03 am   Post subject: (No subject)

well... you could use a mathematical method of Matrix Encoding... but unless you've taken Grade 12 or OAC finite math... I doubt you know how to do it... plus, it might be a bit odd making the code, but I could probably do it for you... maybe...

What if you apply a mathematical formula to it? Say 3X-20=Y when you encode it. Then to decode it it's just X=(Y+20)/3

Alternatively; maybe you can write an algorithm to convert the text to letters using the chr(X) function. So each number would output to the .txt by Y=chr(X), then reading it back in, you can use X=ord(Y). ord returns the number equivilent of the character.

It's still possible someone could write a program to do that though... lol, if I did write that matrix encoding, I can almost guarantee you no one would break it (unless they manage to decode the .exe and found the encoding matrix)
Tony




PostPosted: Tue Nov 26, 2002 8:31 pm   Post subject: (No subject)

lol, someone can reverse engeneer your exe and break your encription Wink

Otherwise, FizixMan is right. You use chr() and ord() to convert strings to ASCII values, then you can apply a math function to encript it. Furthermore you can add one(or more) checking values that suppost to mach sertain other values in the encripted number so that you can't just randomly change some values.

such as in 123 12 is actual number and 3 is sum of all other digits. This way if you change it to 223, it is not valid.

Here's the simpliest encription:
code:

var text:string := "tony"

for i:1..length(text)
put chr(ord(text(i))+1)..
end for


this just moves letters by +1 so A is now B and B is now C.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
p00p




PostPosted: Fri May 07, 2004 8:00 am   Post subject: (No subject)

hm i dont know how to do that
AsianSensation




PostPosted: Fri May 07, 2004 9:38 am   Post subject: (No subject)

what?
spam?
locked?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: