Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the ciphertext and the plaintext. Is it possible to know the key? If not, what do I need to find it?

share|improve this question
up vote 4 down vote accepted


Remember that, in a Vigenère cipher, the $n$-th ciphertext letter is calculated by adding the $n$-th plaintext letter and the $n$-th key letter (where the key is repeated as many times as necessary to make it as long as the plaintext) modulo 26 (for the standard English alphabet), i.e.:

$$c_n \equiv p_n + k_n \mod 26 \tag1$$

(Here, I'll assume the usual conversion between letters of the alphabet and numbers modulo 26, i.e. $\rm A = 0$, $\rm B = 1$, $\rm C = 2$, $\dotsc$, $\rm Z = 25$.)

Conversely, to decrypt the message, the key is subtracted from the plaintext: $$p_n \equiv c_n - k_n \mod 26 \tag2$$

Note that the decryption rule $(2)$ is obtained from the encryption rule $(1)$ by simple algebraic manipulation: we merely need to subtract $k_n$ from both sides of the equation. Conversely, if we know $p_n$ and $c_n$, we can solve for $k_n$ simply by subtracting $p_n$ from both sides of $(1)$:

$$k_n = c_n - p_n \mod 26 \tag3$$

Note that similarity to the decryption rule $(2)$. Basically, to find out the key, given the ciphertext and plaintext, you simply need to decrypt the ciphertext using the plaintext as the key.

share|improve this answer
Got it, thanks a lot!! – Jose Dec 7 '13 at 20:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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