That Blue Square Thing

Computer Science GCSE

Note: this page deals with the old Edexcel GCSE (grades A-G) which no longer exists. I'm keeping it as an archive and because a number of the resources will still apply to newer (grades 1-9) courses. The AQA GCSE CompSci pages deal with a current course.

Data Encryption

Encryption plays a crucial part in allowing people to make effective use of computer networks.

PDF iconData encryption - what it is and why it's important

PDF iconPublic Key and Private Key encryption - a more complex form of encryption

Encryption and caeser cyphers are dealt with on the BBC Bitesize site in the section about Network Securitywiki link. You only need to use the one page.

Caeser Cyphers

A basic cypher (or cipher - either spelling is fine) originally used by the Romans.

PDF iconCaeser Cyphers - basic notes

PDF iconCaeser Cypher exercises - to work through.

Caeser Cypher Program

Here's a program I wrote to allow quick encoding and decoding.

There are almost certainly better ways to do this of course. But the program features a number of important controlled assessment ideas:

Text file iconCaeser Cypher program - copy and paste the code into IDLE

Brute Force Attack

There's aso a brute force caeser cypher cracker. This will allow any text to be entered and each possible caeser cypher decode to be run through. It shows how easy a caeser cypher is to crack and illustrates the power of using a computer in a brute force attack against simple encryption.

Text file iconBrute Force Caeser Cypher decoder program - copy and paste the code into IDLE

Further decomposition

Note: this is more advanced stuff - working at the top of the markbands.

Decomposition is the breaking down of a program into sections. We do this to make it quicker and easier to code the program, to allow programs to be coded by teams of people and to make maintaining programs easier.

We can also use "general" functions to reuse sections of code from other programs. This makes programming much easier to do.

In Python terms, decomposition uses functions to break up the program. To access anything other than the basic marks on controlled assessment you need to be able to break a program up as much as possible.

Decomposing the program

If you look at the first caeser cypher program above you'll see it can be further decomposed. The code() and decode() functions are more or less identical. The only differences are the wording of the input lines and final output line and then one other line of code.

The seventh line of code in each function has either a + or a - in it:

# code function
newindex = charindex + shift

Compared to:

# decode function
newindex = charindex - shift

Because things are so similar I must be able to decompose the functions again to make the code simpler (and shorter). I just need to pay attention to the + or - required and the final message.

Here's how I did it:

Text file iconDecomposed Caeser Cypher program - copy and paste the code into IDLE

I've cut almost all of the code() and decode() functions and written a new function called applyCaeser(). This uses most of the code from the old code() function, with a conditional block thrown in to either code or decode the message.

I can understand if that's a bit difficult to follow by the way. It's the sort of stuff you'd do if you were looking for full marks on controlled assessment.

Frequency of letters in English

One way to crack a code is to look at how often certain characters or patterns of characters appear. This is particularly useful when you have longer sections of text as letters are more likely to occur in certain ways.

The table below shows how often each letter appears in standard English writing.

This is based on looking at thousands of pieces of writing in English and is a good rough guide.

Frequency of letters in English
ABCDEFG HIJKLM
8.2% 1.5% 2.8% 4.3% 12.7% 2.2% 2.0% 6.1% 7.0% 0.2% 0.8% 4.0% 2.4%
NOPQRST UVWXYZ
6.7% 7.5% 1.9% 0.1% 6.0% 6.3% 9.1% 2.8% 1.0% 2.4% 0.2% 2.0% 0.1%

The figures are taken from the Wikipedia article on Letter frequency.

First letters of words

If your text is split into words it can be useful to know which letters are most likely to appear at the start of a word in English.

The seven letters which are most likely to start words in English are:

LetterFrequency
T16.7%
A11.6%
S7.8%
H7.2%
W6.8%
I6.3%
O6.3%

The least frequent letters to start words with in English are z, x and q.

Double letters in words

It can also be useful to know that the letters most likely to appear as double letters in English words are: LL; EE; SS; OO; and TT. FF and MM are also possible double letter combinations.

If you're seeing double letters in your code then you might be able to use this knowledge to help you crack the code.

Common words in English

It can also be useful to look at one, two and three letter words if you have the spacing between words.

See this interesting page from Notre Dame universitywiki link for more pointers on using word and letter analysis to crack codes.