Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Encoder/Decoder w/ Numbers?
Author Message
tlivingston

Posted: 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

FizixMan

Posted: 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

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

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.
Tony's programming blog. DWITE - a programming contest.
p00p

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

hm i dont know how to do that
AsianSensation

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

what?
spam?
locked?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: