Computer Science Canada How to do vigenere cipher?? |
Author: | nelsonkkyy [ Tue Nov 10, 2009 4:29 pm ] |
Post subject: | How to do vigenere cipher?? |
What is it you are trying to achieve? How to do vigenere cipher?? Can someone post a solution to help me plz? Thank you |
Author: | DtY [ Tue Nov 10, 2009 5:15 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
Are you looking for a solution, or help? If you just want help, you'll want to start with a simple caeser cipher. Once you get that, it should be relatively simple to apply a different one on each letter for the vigenere cipher. |
Author: | nelsonkkyy [ Tue Nov 10, 2009 5:49 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
How to do a simple caeser cipher?! i have no idea. |
Author: | Tony [ Tue Nov 10, 2009 5:51 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
Wikipedia FTW -- http://en.wikipedia.org/wiki/Caeser_cipher |
Author: | nelsonkkyy [ Tue Nov 10, 2009 5:55 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
can some one make an example? |
Author: | Dan [ Tue Nov 10, 2009 6:02 pm ] | ||
Post subject: | RE:How to do vigenere cipher?? | ||
The wikipedia artical tony linked expilains it rather well but the pesdo code would be somthing like this:
This assumes the letter x is repsented by a system such as A=0, B=1, C=3, .... Z=25. You can do this easly if you give some thought as to how chars are repesented in ASCII. Note that the value of 'A' in ASCII is 65 and 'B' in ASCII is 66...... 'Z' is 90. |
Author: | nelsonkkyy [ Tue Nov 10, 2009 6:16 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
it does not work/.\ |
Author: | Tony [ Tue Nov 10, 2009 6:29 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
What do you mean it does not work? |
Author: | nelsonkkyy [ Tue Nov 10, 2009 6:44 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
the mod dosen't work |
Author: | nelsonkkyy [ Tue Nov 10, 2009 6:52 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
can someone make a vigenere cipher example for me plz?? |
Author: | nelsonkkyy [ Tue Nov 10, 2009 7:59 pm ] | ||
Post subject: | Re: RE:How to do vigenere cipher?? | ||
Dan @ Tue Nov 10, 2009 6:02 pm wrote: The wikipedia artical tony linked expilains it rather well but the pesdo code would be somthing like this:
This assumes the letter x is repsented by a system such as A=0, B=1, C=3, .... Z=25. You can do this easly if you give some thought as to how chars are repesented in ASCII. Note that the value of 'A' in ASCII is 65 and 'B' in ASCII is 66...... 'Z' is 90. SO how do i write like"a=0" for each letters |
Author: | Dan [ Tue Nov 10, 2009 8:23 pm ] | ||||||||
Post subject: | RE:How to do vigenere cipher?? | ||||||||
It's pseudocode and is not turing: http://en.wikipedia.org/wiki/Pseudocode mod in this case means the modulo operation: http://en.wikipedia.org/wiki/Modulo_operation If you look at an ASCII table ( http://www.asciitable.com/asciifull.gif )the capital letters values should look like this:
So if you where to say the value of a letter is X then X - 65 would get you:
In turing you can covert a character to it's ASCII value with the ord command: http://compsci.ca/holtsoft/doc/ord.html And you can convert an integer to it's conrpsonding character value with chr: http://compsci.ca/holtsoft/doc/chr.html So the code for converting a character to a number such that A=0, B=1, C=2, .... Z=25 would look somthing like:
and to convert it back:
Note that this only works for capital letters as lower case letter have diffrent values. If you want your chiper to handel both you will either have to convert them to upper case before encrypting or change how the chiper works to keep the case intack. |
Author: | nelsonkkyy [ Tue Nov 10, 2009 8:36 pm ] | ||
Post subject: | Re: RE:How to do vigenere cipher?? | ||
|
Author: | Dan [ Tue Nov 10, 2009 9:23 pm ] | ||
Post subject: | RE:How to do vigenere cipher?? | ||
Well thats a start, however there are some problems. First "x := ord(myChar) -65" witch i posted is how to go from ascii code values of capaital letters to A=0, B=1, C=2, ... Z=25 type values. So you still need to use the key on the chipertext. Also the ord command is used on characters and not strings. Here is some code to work with:
plaintext(i) Should return the character at index i in the string plaintext. So if "Hello World" was input and i was 2, it would be equal to 'e' (if i rember how string indexs in turing work correctly). ord(plaintext(i)) converts the char from plaintext(i) to an integer (from the ASCII table). Subtracting it by 65 bring it from A=65, B=66, ... Z=90 to A=0, B=1, ... Z=25. The result is stroed in x (witch you need to declair some where above the for loop). Give some thought to it and try to replace the comments with the correct code. Also i should note that you are inputing key as a string. For this chiper the key is a integer, so you should either input an integer or convert the string to an integer. |
Author: | nelsonkkyy [ Tue Nov 10, 2009 10:00 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
can you send an example for me plz. I still can't do it. my email:nelsonmilk@hotmail.com |
Author: | Tony [ Tue Nov 10, 2009 10:10 pm ] |
Post subject: | Re: RE:How to do vigenere cipher?? |
nelsonkkyy @ Tue Nov 10, 2009 10:00 pm wrote: can you send an example for me plz. I still can't do it.
When you say "example", do you mean "solution"? |
Author: | nelsonkkyy [ Tue Nov 10, 2009 10:22 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
Ya..Solution |
Author: | DemonWasp [ Tue Nov 10, 2009 10:37 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
We don't do those here. We will help you once you've made an honest effort yourself and have attempted to research the subject or try some code. Until then, read the tutorials and approach the problem this way: How would you do this with nothing more than pencil and paper? Take the place of the computer and understand what the computer needs to do to solve the problem. Once you understand that, telling the computer how to do those things is pretty simple. |
Author: | Dan [ Tue Nov 10, 2009 10:37 pm ] |
Post subject: | RE:How to do vigenere cipher?? |
We don't give solution's or do you work for you here. Since the magoity of users asking questions are students working on assingments, that would be cheating. Asking for solution's to home work assingments is aginsnted the rules of this site and can end in you being removed from it if it is done reaptedly. I recomend you find a good turing resource (book, tutorial, or even the turing doc: http://compsci.ca/holtsoft/doc/) and try to work threw the problem with the help we have posted so far. If you run in to problems, ask specific questions and post what you have done so far. Your next step should be filling in the % use key on x here line. Looking at my first code with the pesdocode and the wikipeida page for the vigenere chiper will help you do this. Also check out the turing doc page on mod here: http://compsci.ca/holtsoft/doc/mod.html and the wikipedia page i posted about the modulus opeartion |
Author: | getskillsordietrying [ Fri Nov 11, 2011 9:15 am ] |
Post subject: | Re: How to do vigenere cipher?? |
can anybody please post their viginere program i really can't do it on my own i dont get it |
Author: | mirhagk [ Fri Nov 11, 2011 10:03 am ] |
Post subject: | RE:How to do vigenere cipher?? |
We have given you more than enough information to do it. If you can't at least attempt it, we really can help you anymore. And if you can't do the course without copying someone else's code, then well maybe you should consider dropping the course, or putting a little more effort into it. |