# Is this the mathematical equation for the Vigenere Cipher

Is this the mathematical equation for the Vigenere Cipher or something else and if something else what is it?

Where t is the letter of plain text and n is the position of t within the text and c is the ciphered character.

For 't' and 'c' taking a as 1 and z as 26.

((t + n) > 25 -> c = (t + n) - 25) ^ ((t + n) <= 25 -> c = (t + n))

-
Sorry I ment a zero based index (a as 0 and z as 25) thanks to @fgrieu for pointing out my mistake. – Chris Dec 18 '13 at 15:13

NO, the question does not contain the mathematical equation for the Vigenere Cipher with plaintext t and ciphertext c in thet set $\{1\dots 26\}$ (with the letter a as 1 and the letter z as 26), and displacement (or key) n, for two reasons:

• the best interpretation I can make of the expression given is by considering -> to be the $\implies$ mathematical symbol, and ^ to mean logical XOR (or perhaps logical OR), that is one of the left thing or the right thing holds (possible meanings of the word one are equivalent in the context); but even with these assumptions, for n of 1 (meaning next character, circularly) the expression given maps the plaintext y (coded by t of 25) to the ciphertext a (coded by c of 1) instead of the desired z (coded 26);
• the expression given does not parse (to me) as a mathematical equation.

With the original formalism, the Vigenere Cipher with plaintext t and ciphertext c in $\{1\dots 26\}$, and displacement n in the set $\{0\dots 26\}$, a correct expression would be:

((t + n) > 26 -> c = (t + n) - 26) ^ ((t + n) <= 26 -> c = (t + n))

and a passable mathematical equation would be: $$t\mapsto c=((t+n+25)\bmod 26)+1$$

If we use the set $\{0\dots 25\}$ for plaintext and ciphertext, we get the nicer $$t\mapsto c=(t+n)\bmod 26$$

or in the original formalism the expression

((t + n) > 25 -> c = (t + n) - 26) ^ ((t + n) <= 25 -> c = (t + n))

-
Sorry yea I ment zero based index (0 to 25). Although what I was trying to do with the equasion (the -> and ^) was mathematically write an if else statement as in if((t + n) > 25) then c = (t + n) - 25 elseif((t + n)) <= 25 then c = (t + n) Could you please explaine what the ↦ means in your equation though. And now with this if elseif statement would my -> mean ⟹ like you interpreted? – Chris Dec 18 '13 at 15:11
@Chris If you click on 'edit' below any answer you can read the plaintext that gets rendered into Latex with mathjax. The symbol you asked about is created with the command "\mapsto" and the symbol indeed does have this meaning. In the context above, assuming we represent the cipher by the function $f$, then the expression $t\mapsto c=((t+n+25)\bmod 26)+1$ is equivalent to $f(t)=c=((t+n+25)\bmod 26)+1$. To say the original out loud: "t maps (under the Vigenere Cipher) to..." – Kaya Dec 18 '13 at 15:49
@Chris: Welcome to CSE. Adding to the previous comment: to see what's in a math statement, right-click on it and use "Show Math As.. TeX Commands". Also: depending on your programming language, what you actually wanted may be c = (t+n)%26; (without any test). – fgrieu Dec 18 '13 at 16:11
Thanks guys, I think i get it now. – Chris Dec 18 '13 at 17:21
So would this be right as well then? $$t \mapsto c = \begin {cases} (t + n) > 25 & (t + n) - 25 \\ t + n \le 25 & (t + n) \end {cases}$$ – Chris Dec 18 '13 at 17:32