Proj 18 in CNIT 120: Encrypting an Image in ECB and CBC Modes (15 pts.)

What You Need


To see the flaws of the ECB (Electronic Code Book) encryption mode, and compare it to CBC (Cipher Block Chaining).

Activating the Administrator Account

Cryptool was written for Windows XP, and won't install properly on Windows 10 unless you are using the built-in Administrator account.

At the lower left of the desktop, in the Search box, type COMPUTER.

Right-click "Computer Management" and click "Run as Administrator". If a User Account Control box pops up, approve the privilege escalation.

In the left pane, expand "Local Users and Groups" and click Users.

In the right pane, right-click Administrator and click Properties, as shown below.

In Administrator Properties, clear the "Account is disabled" check box, as shown below. Click OK.

Right-click the Start button, point to "Shut down or sign out", and click "Sign out".

Log in as Administrator. No password is needed.

Wait while pretty messages appear, such as "Lots of great features to get excited about". After a few minutes a desktop will appear.

Install CrypTool

Open a browser and go to

Download and install any version of CrypTool 1. I used CrypTool 1.4.30.

Don't get CrypTool 2, it's completely different.

Getting a Starting Image

Use Google to find a simple logo to work with. For this demo you need a file with regions of identical color, not a blurred or textured image.

Open the file in Paint and save it as a 24-bit BMP.

In CrypTools, click File, Open. In the lower right of the "Open" box, select "All files (*.*)", as shown below on this page. Open the BMP image.

The image opens in hexadecimal view, as shown below on this page.

Click "Encrypt/Decrypt", "Symmetric (modern)", "DES (ECB)", as shown below on this page.

In the "Key Entry: DES (ECB)" box, enter a Key of AB CD, as shown below on this page. Click Encrypt.

The file is encrypted now. Click Windows, Tile. The image below shows the original file on the bottom, and the encrypted version on the top.

The original image starts with the letters BM -- that starts the file header for a bitmap.

The upper file is encrypted. Notice that the BMP header is also encrypted, so this file won't open in an image viewer anymore.

Highlight the first 42 bytes of the original image, as shown below. Right-click the highlighted region and click Copy.

In the the "Encoded Copy/Cut" box, accept the default selection and click OK.

Carefully highlight the same region of the encrypted file, right-click, and paste the original header there.

Now both files start with BM -- they both have valid bitmap headers.

Click in the encrypted file's window, and then click File, Save. In the bottom of the "Save As" box, select "All files (*.*)".

Save the file with the name DES_ECB.bmp.

Open the encrypted bitmap in Paint.

Here is the result: an encrypted image in ECB mode, which retains a lot of the structure of the original image.

This happens because in ECB (Electronic Code Book) mode, each repeated 8-byte block of the image results in identical ciphertext.

Saving the Screen Image

Make sure the image shows some of the shapes in the original image, as shown above.

Save a whole-desktop capture with a filename of "Proj 18a from YOUR NAME".

Encrypt the original image again, using DES in CBC mode. Paste in the header again, and save the result with a filename ending in .bmp

Open the encrypted image. Now all the structure from the orginal image is scrambled, as shown below.

This happens because CBC (Cipher-Block Chain) mode uses the result of encrypting each 8-byte block to create a pseudorandom "nonce" to include when encrypting the next block, so even if a block of input repeats, the output is still different every time.

Saving the Screen Image

Make sure the image shows only random noise--no structure from the original image, as shown above.

Save a whole-desktop capture with a filename of "Proj 18b from YOUR NAME".

Turning In Your Project

Email the images to with a subject of "Project 18 from YOUR NAME".


MPICT Summer Faculty Development Week: Cryptography Class by Casey W. O'Brien

Wikipedia page: Cipher-Block Chaining (CBC) and Electronic Codebook (ECB) modes of DES encryption.

Last modified 4-28-16