Hello, everybody!
Welcome to my office.
As you can see, it's all glamour.
Last time, I set you a code challenge,
and I invited you to break this code.
And I said that the first person to break this code
would win the moderately fabulous prize
of a signed copy of "The Code Book" by Simon Singh.
Well, a lot of people entered.
It was very tense.
So tense, my hair fell out,
as you can see.
But we do have a winner.
And the winner is
Nightmare2u.
So congratulations to you,
and your prize will be winging its way towards you.
And what Nightmare2u realized was
the code I set
is an example of something called a
'Vigenère cipher.'
Now, you may be familiar with this type of code,
which is called a 'Substitution cipher.'
This is where you replace one letter for another.
So, in this example, I've written out
A to Zed at the top,
and underneath, I've written out the letters
in the code.
So A becomes P,
B becomes K,
C becomes B, and so on.
So if I write this word here, like 'beetroot,'
then we get K-W-W-C-E-H-H-C.
Now, to break this code
is not too difficult.
What you do is you look for the most common letter.
So let's say, for example, if you E becomes a W,
like here,
then I would expect
W to be the most common letter
in the code,
because E is the most common letter in English.
T is the second most common letter in English,
and A is the third,
and so on.
So you can use this idea to work out which letter is which.
There are other things you can do.
I mean, for example, if you have a double O, like here--
so if you have a double letter,
it becomes a double letter in the code, as well.
So these things are clues,
and they tell you which letter is which.
So you can break this without too much trouble.
Vigenère just takes that one step further.
Let me show you how it's going to work.
To do the Vigenère cipher,
first of all, you're going to need a key word.
So, for example, let's take a key word
to be 'ghost.'
OK.
Then you're going to write out a message.
Let's say it's something like this,
which says 'move to the hill,'
so, very military.
And you write out the key word above it.
GhostGhostGhost, repeated without spaces.
Now you need this table,
which might look a bit complicated,
but the first line is just A-B-C,
up to Zed.
The second line is B-C-D-E--
I've shifted the alphabet one place across.
The third line starts with a C,
so it's C-D-E-F,
and then the fourth line is D-E-F-G.
So I keep shifting the alphabet
one place across,
and I've got 26 lines here.
Now, as you can see, I've highlighted
the lines that begin with G, H, O, S and T,
for 'ghost.'
Now, let's take our message again.
Now, this was the message--'move to the hill.'
And what I do is I'm going to use that table,
the first letter is an M,
so
what I do
is I go
to row G--
there's row G--
I find column M,
and in the middle
is the letter S.
So this
becomes
S, like that.
OK. Let's do the second letter.
So the O.
For the O,
you go to row H,
for 'ghost,'
you go to column O up here,
and you find, in the middle,
the letter V.
So they meet at the letter V,
and I write that in.
OK, so that's my second letter.
Now, you keep going,
and this is what you'll get.
Now, notice here
the two L's in 'hill'
become two different letters.
As well as that, these two W's
come from
two different letters.
They come from an E, and they come from a T.
So you can't use that trick
that we did with the Substitution code.
So a double letter
doesn't necessarily become a double letter in the code.
So this is a more difficult code to break.
But you can break this, too.
The way you break it
is you look for repeated letters.
So, for example, 'the'--
the word 'the' here
becomes A-V-W.
Now, if A-V-W appears more than once,
I can assume
that it's the word 'the.'
It just happens to be underneath
the same three letters of the key word--
the H, O and S.
And so it's encoded in the same way.
So the code I set you, that's what we're going to do.
This is the code I set you,
and, if you look,
I can find
V-Y-C--
you see how it begins with a V-Y-C--
I can find that
let me see,
four different times.
V-Y-C appears four different times.
Not only that,
but there's this
string of letters--you may have noticed
this string of letters
appears twice.
Now,
we can use this to break the code.
Using, or considering the distances,
we can work out that the key word
was eleven letters long.
Now, assuming that V-Y-C is the word 'the,'
we can start to work backwards.
We can use
this table.
We can start to work backwards
and I can get that the first three letters
of the key word
was C-R-Y.
Now, with a bit more to-ing and fro-ing,
you can work out
that
they key word was a eleven letter word
and it was the word
'cryptograph.'
Using the key word and the code,
you can now completely work backwards,
and you find
the message, and this was the message.
And it says
"The code you have broken
is an example of the Vigenère cipher
that was put in its final form
by the French diplomat
Blaise de Vigenère." I may have pronounced that wrong.
"It is an example of a polyalphabetic cipher.
In other words, the cipher is constantly changing."
As you saw, we kept changing the line
that we were using
in the table.
It's a brilliant code
that was first broken
by the famous engineer Charles Babbage."
You may have heard of Charles Babbage before.
That's a brilliant British engineer and inventor,
who broke this code, but when he broke the code,
he kept it secret.
The reason that he kept it secret possibly
was because of the Crimean War.
And so he kept it secret
so that we could break Vigenère codes,
enemy codes, without revealing that we could do that.
And that's how you do it.
It's been fun.
I will hope to do this again some time.
And, as usual,
if you have been,
thanks for watching.