# K Friedman - two texts explanation

I read the $K$-Friedman test to determine the period of a Vigenère ciphertext, and I understand something like this:

$K$-Friedman test tries to find out what period of the cipher by calculating some values of $K(C,C^n)n$, where $C^n$ is the ciphertext with $n$ shifts to the left, thereby determining the most likely value of the cipher.

But deep down, what the Friedman Test does? Overlaps two texts and see coincident indexes? Can anybody explain this method better?

• I'm assuming you took a look at this section on Wikipedia's Vigenere cipher article about the test. The last paragraph, beginning with "A better approach..", to me seems to explain what you are looking for. Jan 4, 2016 at 18:27
• Yes is that section but I can't understand this. Can you give me an example more simple ? I can't undestand if two texts are overlaped and the function gives to us the index-of-coincidence. I'm very confused.
– PRVS
Jan 5, 2016 at 10:23
• Did you see this example (also on Wikipedia)? Jan 5, 2016 at 12:41
• Yes but I want to know if two texts are overlaped and the function gives to us the index-of-coincidence. I'm very confused.
– PRVS
Jan 9, 2016 at 14:57
• I suggest you to take a look at nku.edu/~christensen/1402%20Friedman%20test%202.pdf Jun 3, 2016 at 12:07

Just for simplicity lets assume that your short period "password" was just XORed with plaintext. So we have encryption procedure like:

for(int i = 0; i < plaintext_len; i++){

ciphertext[i] ^ ciphertext[i + password_len] =

Note that if you have a 0 char in the result, than the corresponding symbols in plaintexts are equal. The probability of such event for natural text is far from uniform and depends on plaintext language (for English it's 0,0644). If the period guess is wrong, the probability that a particular character in the result is 0 equals $1/m$ where $m$ is the number of symbols in your alphabet, for English it's about 0,03856.