Lesson 3
Simple steganography
Steganography is about hiding a message rather than encrypting it. This can be done in a number of ways:
Steganography is about hiding a message rather than encrypting it. This can be done in a number of ways:
- You can simply scramble your message within a random cover text or make the message a slightly different shade/font/size to the cover text. For a not so subtle example: There once was a lady who lived in an upside-down shoe.
- On webpages you can also hide content in a location off the side of the page or ‘up in the air’ as if the page was 3D. For those of you maths-oriented people - a 2D webpage effectively uses the ‘x’and ‘y’ axes for locating information. To hide something you locate it along the ‘z’ axis. Please note, hiding text in webpages (depending on what/how) isn’t always liked by search engines / hosting providers, so I’m not recommending it lots *G*
- Steganography is also used online to add a virtual hidden watermark to images so that the owner of the image maintains the ability to show it’s theirs.
- There is also the simple (and not really so modern) method of using the first or last letter of words in a sentence. For example: Indonesian lions in klutzy Europe can always kick elephants.
--------------------------------
Rail-fence cipher
This transposition cipher is named after the pattern which is used to encode the message and the simplest way to understand it is by example.
Let’s take the plain-text: Trophy room, six pm.
This transposition cipher is named after the pattern which is used to encode the message and the simplest way to understand it is by example.
Let’s take the plain-text: Trophy room, six pm.
You simply write the plain text in diagonal squares up and down. The cipher text is then formed by going across each line from left to right:
THOX RPYO MIPO RSM
Seeing as the cipher text looks almost nothing like the original text, it’s a fairly decent way of encoding a message. It’s obviously better with longer messages as it separates the letters more from their original neighbours.
Decoding:
Decoding the rail-fence cipher isn't hard, just a bit annoying. For example, if the ciphertext is 15 characters long like above. If you don't know how many rows it is you can create a "dummy" grid as below. For the purpose of this class, no more than five rows will ever be used. Below I've only covered 3- and 4-row options.
The above grids allow you to "guess" what order the letters in the ciphertext are. For example if we try the four row version:
THOX RPYO MIPO RSM = 1 7 13 2 6 8 12 14 3 5 9 11 15 4 10
Putting the letters in order, according to their number, you get: T X M S I .... by this point, it doesn't look like it's working. Of course it could just mean the beginning of the message was "padded" with gibberish so to be sure the entire message should be decoded. As in this case I know it's a three row version, I haven't bothered ;) Using the three row version:
THOX RPYO MIPO RSM = 1 5 9 13 2 4 6 8 10 12 14 3 7 11 15
This gives plaintext: T R O P H Y R.....etc
THOX RPYO MIPO RSM = 1 7 13 2 6 8 12 14 3 5 9 11 15 4 10
Putting the letters in order, according to their number, you get: T X M S I .... by this point, it doesn't look like it's working. Of course it could just mean the beginning of the message was "padded" with gibberish so to be sure the entire message should be decoded. As in this case I know it's a three row version, I haven't bothered ;) Using the three row version:
THOX RPYO MIPO RSM = 1 5 9 13 2 4 6 8 10 12 14 3 7 11 15
This gives plaintext: T R O P H Y R.....etc
------------------------------
Columnar cipher
The easiest way to explain this transposition cipher is via an example...
Plain text: Hidden trapdoor under kitchen table
First step: Write the plain text out in rows of a specific length - I’m going to use rows 5 characters long. Please note, the plaintext was expanded with QDFX to fill it out.
The easiest way to explain this transposition cipher is via an example...
Plain text: Hidden trapdoor under kitchen table
First step: Write the plain text out in rows of a specific length - I’m going to use rows 5 characters long. Please note, the plaintext was expanded with QDFX to fill it out.
Second step: The columns of the grid above have been numbered. Choose a keyword containing as many letters as there are columns. No letter should appear in the keyword more than once. I will use: GLOBE
Third step: Place the letters for the keyword in alphabetical order: B E G L O. These corresponds to columns 1 to 5 respectively - I.e. B = column 1, E = column 2 etc.
The order in which the columns are to be written in the cipher text is dictated by the order of the columns in the keyword:
GLOBE = 3 4 5 1 2
Fourth step: Read off the columns in the order decided in step three and voila, you have your cipher text.
DROECAD DARRHBF EPUKELX HNDNINE ITODTTQ
If the keyword has repeating letters in, you only pay attention to the letter the first time it shows. Here are a few examples:
COFFEE --> COFE --> 1432
CHOCOLATE --> CHOLATE --> 2465173
MAROON --> MARON --> 21543
Deciphering
Third step: Place the letters for the keyword in alphabetical order: B E G L O. These corresponds to columns 1 to 5 respectively - I.e. B = column 1, E = column 2 etc.
The order in which the columns are to be written in the cipher text is dictated by the order of the columns in the keyword:
GLOBE = 3 4 5 1 2
Fourth step: Read off the columns in the order decided in step three and voila, you have your cipher text.
DROECAD DARRHBF EPUKELX HNDNINE ITODTTQ
If the keyword has repeating letters in, you only pay attention to the letter the first time it shows. Here are a few examples:
COFFEE --> COFE --> 1432
CHOCOLATE --> CHOLATE --> 2465173
MAROON --> MARON --> 21543
Deciphering
- Knowing the keyword, you must count the length of it, e.g., GLOBE is 5 letters.
- You then divide the number of letters in the cipher-text by the number of letters in the keyword. In this case: 35/5 = 7. You then know there are 7 letters in each column (please note I have made it obvious above anyway by writing the characters of the cipher text in chunks of 7 characters but this would not always be the case).
- Divide the ciphertext up into groups of this length (7 letters).
- You then need to work out how GLOBE translates into numbers (note we already did this while encrypting it). GLOBE = 34512
- Applying this to the ciphertext:
Now you just write the columns out in order and voila, you have decoded it - make sure you write them as columns not rows ;) In this stage you should end up with the same grid we first used to encode the text :)
I.e. you first write out:
H
N
D
N
I
N
E
Then to the right add the second column:
H I
N T
D O
N D
I T
N T
E Q
etc :)
Double transposition
For double transposition, columnar transposition is simply carried out twice. For example after the initial transposition giving:
DROECAD DARRHBF EPUKELX HNDNINE ITODTTQ
The above text is treated as the "plaintext" and written into a grid as per the original plaintext. A new keyword is used to read off the columns then created. For example, if we take the keyword: VENUS = 51243 the final ciphertext would be:
CRELNTQ DARPXIO RDHUHND EAFEDIT ODBKNET
I.e. you first write out:
H
N
D
N
I
N
E
Then to the right add the second column:
H I
N T
D O
N D
I T
N T
E Q
etc :)
Double transposition
For double transposition, columnar transposition is simply carried out twice. For example after the initial transposition giving:
DROECAD DARRHBF EPUKELX HNDNINE ITODTTQ
The above text is treated as the "plaintext" and written into a grid as per the original plaintext. A new keyword is used to read off the columns then created. For example, if we take the keyword: VENUS = 51243 the final ciphertext would be:
CRELNTQ DARPXIO RDHUHND EAFEDIT ODBKNET
-----------------------------
Route Ciphers
Example
For example, to make mine into a 30 letter plaintext so that I can use a 6×5 grid I would do the following:
SECON DROWA BOVET HEDIC TIONA RYXXX
I’ve divided the above into groups of 5 ready to enter into my grid and as you may have noticed, I’ve added 3 X’s on the end to make it up to 30 letters.
4. Enter the plain text into your grid. You can either write the message going along the rows (as above) or down the columns.
Example
- Choose your plaintext. In this case I’m going to use: ‘Second row above the dictionary’ Yes, ok so it’s a bit random, but it’ll work.
- Count the number of letters in your plain text. There are 27 letters in mine.
- Work out what numbers that can be divided into - i.e. 27 = 9 x 3. Thus, I can use a 9 x 3 grid. Note: If your number of letters does NOT divide by numbers easily (ideally you want things as close together as possible, like 4×5, or 6×5) just add a number of one uncommon letter on the end.
For example, to make mine into a 30 letter plaintext so that I can use a 6×5 grid I would do the following:
SECON DROWA BOVET HEDIC TIONA RYXXX
I’ve divided the above into groups of 5 ready to enter into my grid and as you may have noticed, I’ve added 3 X’s on the end to make it up to 30 letters.
4. Enter the plain text into your grid. You can either write the message going along the rows (as above) or down the columns.
5. Take the text off your grid in some pattern of rows/columns. I’ve given some examples of ways in which this can be done below. Please note: the rows are horizontal, the columns vertical.
As you have probably noticed, some ways work better than others depending on how you’ve written the plain text in (columns/rows). I’ve also tried to keep the letters grouped in blocks of 5 or 6 just to make it easier to see what I’ve done. The pattern you use to take the letters off the grid can be whatever you want, however, there comes a point when it can become too complex to be feasible for decoding easily.
Also, bear in mind that in some cases, the person will not know what grid size you have used or how you’ve written in the code.
In the first and third cipher texts created above the ‘XXX’ is all together which makes it obvious that the cipher text has been extended -and- that the X’s are next to each other in the way you’ve taken it off the grid - this is another aspect to consider in choosing your method.
Decoding
To decide the route cipher you must:
- Every second row starting from the top one. (Not a very good choice seeing as the plain text was written in in rows)
- SECON BOVET TIONA DROWA HEDIC RYXXX
- Every column starting from the right hand one and the bottom of each column:
- XACTAN XNIEWO XODVOC YIEORE RTHBDS
- Spiralling inwards -anti-clockwise from the bottom left ‘R’:
- RYXXX ACTAN OCESD BHTIO NIEWO ROEDV
As you have probably noticed, some ways work better than others depending on how you’ve written the plain text in (columns/rows). I’ve also tried to keep the letters grouped in blocks of 5 or 6 just to make it easier to see what I’ve done. The pattern you use to take the letters off the grid can be whatever you want, however, there comes a point when it can become too complex to be feasible for decoding easily.
Also, bear in mind that in some cases, the person will not know what grid size you have used or how you’ve written in the code.
In the first and third cipher texts created above the ‘XXX’ is all together which makes it obvious that the cipher text has been extended -and- that the X’s are next to each other in the way you’ve taken it off the grid - this is another aspect to consider in choosing your method.
Decoding
To decide the route cipher you must:
- Count the number of letters to find the possible grid sizes (if you don't know it). For example if your ciphertext is 40 letters long possible grid sizes are: 2x20, 20x2, 10x4, 4x10, 5x8, 8x5.
- Create grids of these sizes and try writing the ciphertext in using a variety of patterns - serpentines, spirals, row by row, etc.
- Eventually (or instantly) find the solution, it's very much pot luck as to how quickly you can solve these really. Obviously using some logical method helps.
---------------------------------
Onto your third ASSIGNMENT.