Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 3 down vote accepted

Yes.

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
1  
Got it, thanks a lot!! –  Jose Dec 7 '13 at 20:30
add comment

Your Answer

 
discard

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.