Computer Science Canada
Code / Decode
|Author:||Win OOPs [ Tue Oct 01, 2002 8:34 am ]|
|Post subject:||Code / Decode|
Ok Tony.... [Soprano]
U suggested to come here......
a coding/decoding program
like the one they made to use in WWII...
But i need help making my own... using letters and numbers ....
So when the user inputs the message..... it should give the code in output.... and vice versa...
Thanx for the help.....
|Author:||Tony [ Tue Oct 01, 2002 9:22 am ]|
thx for comming. Here's the simpiest way to do so:
this will output "bcd" which is the next letter from the original. Such as A is B and B is C. to reverse it, you just have to change +1 to -1
now I guess this is quite easy to crack. So if you want to make it more compilcated you can change the +1 to some more complex math function.
The idea behind this is:
chr will output an ASCII character based on the interger provided
ord takes an ASCII value of character provided
+1 increases ASCII value obtained by 1 to code the message
I hope this helps.
Also a cool encoding method is to use a seeded random function, but I don't think WinOOT allows that. I know you can do that in VB though.
|Author:||Win OOPs [ Tue Oct 01, 2002 2:23 pm ]|
Ok thanx... but Wut if i want to the user to input the message to encode....
and the alphabets will have a Same value.... each time so that if "A" is typed.... it can recognize it by same number enter.....
P.S. You can tell that i don't know anything about TURING.... but what happened was... I took the course... but then didn't even look at it for more than an year and a half.... and now I am taking it again....
And yes.... if you are suspicious.... this is not a project... or class work.....
I was going over some loops and strings and suddenly i thought of the idea... but then i got stuck and couldn't even think of anything.... except this.... :
and the letters as variables... will equal to a Constant value and if user enters that "A" it would give the user 26.... no matter how many times... the letter comes in the message
I know this is the longer way of doing this program..... but had no choice....
And plz.... don't laugh at me ...... I might have sounded dumb... but i can't help it.... Mr. Soprano...
|Author:||Tony [ Tue Oct 01, 2002 11:19 pm ]|
Hey, my program runs a loop from 1 to the length of the string, so it can code/decode a message up to 255 characters, including spaces. Just don't forget to put :* at the end of get as in get name:* to get all characters including spaces.
and try changing the value of the varaible in the program from "abc" to something else to see how it affest the output.
Also, don't worry about the way you do your programs. We all were new to all of this as some point. Thats why S.W.A.T. is here to help you
And now that you know how to work with ASCII values, code/decode program should be easy.
|Author:||Win OOPs [ Wed Oct 02, 2002 4:47 am ]|
Thanx that helped alot....
but i when i wrote the put command and when i put get name :*
it just gives me one output
Thanx for the support....
|Author:||Tony [ Wed Oct 02, 2002 5:13 am ]|
ummm... well ya.
What get name:* does is that it takes everything you type as an input including spaces.
The problem with regular get is that if you have a SPACE as a part of your string, it will cut the string into two varaibles and part after the SPACE will be passed to the next get.
Such as if in code:
for get a you type "blah blah", it will skip get b and for output a is "blah" and b is "blah"
if insdead of get a you would put get a:* it will take "blah blah" and put all of it into variable a.
I hope this explains how get statments work.