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))
  • $\begingroup$ Sorry I ment a zero based index (a as 0 and z as 25) thanks to @fgrieu for pointing out my mistake. $\endgroup$ – 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))

| improve this answer | |
  • $\begingroup$ 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? $\endgroup$ – Chris Dec 18 '13 at 15:11
  • 1
    $\begingroup$ @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..." $\endgroup$ – Kaya Dec 18 '13 at 15:49
  • $\begingroup$ @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). $\endgroup$ – fgrieu Dec 18 '13 at 16:11
  • $\begingroup$ 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} $$ $\endgroup$ – Chris Dec 18 '13 at 17:32
  • $\begingroup$ @Chris: Not quite. Make that $t \mapsto c = \begin {cases} (t + n) \ge 26 & (t + n) - 26 \\ (t + n) \lt 26 & (t + n) \end {cases}$ (notice you MUST substract $26$, not $25$; the tests ar equivalent, but it is best to use the same constant everywhere); or just use $t\mapsto c=(t+n)\bmod 26$, which means just what you want, and has the added advantage of working with $n=30$, and also (for the approriate definition of $\bmod$, which is not quite that of % in the C language) with $n=-1$. $\endgroup$ – fgrieu Dec 18 '13 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.