# Crack a polyalphabetic cipher given a pair of (plaintext, ciphertext) encrypted by it

The original question only states that a classical cipher is used, and I am going to articulate 1) why I think a polyalphabetic substitution cipher is used AND 2) my attempts so far.

## The Question

c1 = rhlxhei rb niu ir-wbbxug "qeejv," rgj mbfo sdg
m1 = friends by the so-called "posts," but they can
c2 = fypx pd jkx teoyde nupyd wbd hhtfmo yqvlfqeu
m2 = ?


## Which type of cipher is used

1. If it is a transposition cipher, then for each character, the number of its occurrences should be identical in both plaintext and ciphertext. (Contradiction)
2. It is a monoalpbetic substitution cipher, the same character in plaintext should be mapped to the same character in ciphertext. (Contradiction)

As a result, it should be a polyahplabetic substitution cipher.

## My Attempts

### IC (Index of Coincidence)

I googled that Index of Coincidence can be used to guess the key length, but that is based on that the length of the ciphertext is statistically long enough.

### Calculate Offsets

I then realized that if Vigenère cipher is used, then for each character of m1 and c1, I can calculate the offset between them, and figure out the repeating pattern in the offsets.

To make it clear, offsets[i] = (c[i] + 26 - m[i]) % 26, and offsets is printed below

12 16 3 19 20 1 16 16 3 20 1 16 16 3 20 1 16 12 16 3 1 16 12 16 3 16 12 16 19 20 1 16 16 3 19

However, there are two difficulties.

1. Although there are some repeating numbers (e.g. 16, 19, 1, etc.), I failed to extract the exact pattern from the offsets.
2. If I directly applied those offsets (reversely) to c2, the result does not make sense (m2 = rosq qt mey jhiztq qvfkt mnt bijvph otofggux'), so I am wondering maybe the plaintext is incorporated into the key in some way.

Please correct me if the process described above is somewhat wrong and direct me if there is a certain way to take advantage of the known (c1, m1) pair. Thank you!