Hello! I am trying to understand the Vigenere cipher, but I really do not grasp the concept. The project gives me the following as an example:

message: b a r r y i s t h e s p y

```
keyword phrase: d o g d o g d o g d o g d
resulting place value: 24 12 11 14 10 2 15 5 1 1 4 9 21
coded message: ymlok cp fbb ejv
```

Let’s take for example the first letter, b and d. How does it get to 24? I have tried adding indices, getting individual indices and nothing relates. The second letter also does not match. As for r and g, i subtract them and get 11, so it does relate.

You should be doing addition modulo (size of the alphabet).

If you’re not familiar with the integers modulo n (where n is the size of something), it basically represents a group of numbers that has an operation associated with it and closure (meaning that no operations on the group of numbers will take you outside that set of numbers).

A simple example is the integers modulo 4 are just the numbers {0,1,2,3}.

You’ll notice that if you add any integers modulo 4, any number of times, you will just get one of those numbers. For example

(2 + 2) % 4 = 0

(2 + 2 + 1) % 4 = 1

(2+3) % 4 = 1

(0 + (-1)) % 4 = 3 (think about why this is true)

(5 + 1) % 4 = 2

In your case the addition would be modulo the size of the alphabet you’re using (so probably % 26, but if it were a different alphabet set you would adjust it accordingly)

1 Like

Thank you. I actually did it and it worked. I don’t know why, but it is backwards. So I needed to subtract.