
-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 4:29 pm

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

-----------------------------------
DtY
Tue Nov 10, 2009 5:15 pm

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.

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 5:49 pm

RE:How to do vigenere cipher??
-----------------------------------
How to do a simple caeser cipher?!
i have no idea.

-----------------------------------
Tony
Tue Nov 10, 2009 5:51 pm

RE:How to do vigenere cipher??
-----------------------------------
Wikipedia FTW -- http://en.wikipedia.org/wiki/Caeser_cipher

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 5:55 pm

RE:How to do vigenere cipher??
-----------------------------------
can some one make an example?

-----------------------------------
Dan
Tue Nov 10, 2009 6:02 pm

RE:How to do vigenere cipher??
-----------------------------------
The wikipedia artical tony linked expilains it rather well but the pesdo code would be somthing like this:

[code]
CipherText = ""

For letter x in PlainText
    y = (x + Key) mod 26
    append y to ChiperText
End
[/code]


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.

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 6:16 pm

RE:How to do vigenere cipher??
-----------------------------------
it does not work/.\

-----------------------------------
Tony
Tue Nov 10, 2009 6:29 pm

RE:How to do vigenere cipher??
-----------------------------------
What do you mean it does not work?

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 6:44 pm

RE:How to do vigenere cipher??
-----------------------------------
the mod dosen't work

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 6:52 pm

RE:How to do vigenere cipher??
-----------------------------------
can someone make a  vigenere cipher  example for me plz??

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 7:59 pm

Re: RE:How to do vigenere cipher??
-----------------------------------
The wikipedia artical tony linked expilains it rather well but the pesdo code would be somthing like this:








SO how do i write like"a=0" for each letters

-----------------------------------
Dan
Tue Nov 10, 2009 8:23 pm

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:

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:


x := ord(myChar) -65


and to convert it back:

myChar := chr(x + 65)



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.

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 8:36 pm

Re: RE:How to do vigenere cipher??
-----------------------------------

var plaintext,key,ciphertext:string

put "Enter a plaintext to encrypt"
get plaintext
put "Enter a key word"
get key

for i:1..length(plaintext)
ciphertext := ord(plaintext) -65

put ciphertext
%like that???%


-----------------------------------
Dan
Tue Nov 10, 2009 9:23 pm

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:

for i:1..length(plaintext)
   x := ord(plaintext(i)) -65 
   % use key on x here
   % convert x back to a char
   % append x to chipertext string
end for


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.

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 10:00 pm

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

-----------------------------------
Tony
Tue Nov 10, 2009 10:10 pm

Re: RE:How to do vigenere cipher??
-----------------------------------
can you send an example for me plz. I still can't do it.
When you say "example", do you mean "solution"?

-----------------------------------
nelsonkkyy
Tue Nov 10, 2009 10:22 pm

RE:How to do vigenere cipher??
-----------------------------------
Ya..Solution

-----------------------------------
DemonWasp
Tue Nov 10, 2009 10:37 pm

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, [url=http://compsci.ca/v3/viewtopic.php?t=8808&start=0]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.

-----------------------------------
Dan
Tue Nov 10, 2009 10:37 pm

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

-----------------------------------
getskillsordietrying
Fri Nov 11, 2011 9:15 am

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

-----------------------------------
mirhagk
Fri Nov 11, 2011 10:03 am

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.
