In this coursework, you will demonstrate your ability with the C programming language and its standard library by writing a steganography program which encodes and decodes secret messages in bitmap images.
This coursework contributes to the following learning outcomes of the course:
• Ability to develop efficient, resource-conscious code.
• Practical skills in low-level, systems programming, with effective resource management.
• Ability to articulate system-level operations and to identify performance implications of given systems.
This is an individual assessment. The code and documentation you submit must be entirely your own work.
If you have any questions, please ask me [email protected].
The problem
This coursework involves writing a simple steganography program in C, called steg. steg can operate in two modes — encode and decode — selected by the first command-line argument being e or d.
An RGB colour bitmap image consists of a grid of pixels, each of which has red, green and blue colour values. To encode text inside an image, your program will replace the red value in successive random pixels in the image with characters from the text, outputting a new image.
When encoding, your program will be invoked as:
./steg e old.ppm >new.ppm
It must prompt for a message to encode, and output the new image to stdout (in this case we have redirected it to a file).
To decode the text, your program will compare the new image with the old image, and extract characters from the new one where it differs from the old one.
When decoding, your program will be invoked as:
./steg d old.ppm new.ppm
It must decode the message and output the hidden text to stdout.
The PPM image format
You will work with Plain PPM format images. This is one of a family of simple open source image formats, designed to be read and written easily by C programs. See the PPM specification for full details of PPM and Plain PPM.
A Plain PPM file consists of ASCII text:
P3
comment1
…
commentN
width height
max
r1 g1 b1
r2 g2 b2
r3 g3 b3
…
where:
• P3 - code indicating Plain PPM format
• comment - arbitrary optional comment text
• width - integer number of columns
• height - integer number of rows
• max - integer maximum colour value - usually 255
• ri gi bi - integers between 0 and max for pixel i's red, green and blue values
All integers are in decimal.
(From now on, I will refer to Plain PPM just as PPM.)
Getting started
You will need a Linux C development environment, like we have been using in the practical exercises. This might be:
• a MACS lab machine
• a MACS machine remotely, using x2go
• the MACS Linux Virtual Machine on your own computer
• a regular Linux installation on your own computer
You may like to refer to Hans-Wolfgang Loidl's Linux Introduction.
Cloning the project
You are provided with a template project containing an outline source file. You must use Git and the MACS GitLab Student server to download the template project and to submit the assessment.
First, fork this project.
Then clone your fork on your Linux system, e.g. (replacing username with your username):
git clone [email protected]:username/f28hs-2021-22-cwk1-c.git
Make sure that you can compile the starter code before you start making changes to the steg.c file. Change into the project directory, and run:
make
(This may print some warnings because the code is incomplete.)
As you progress through the coursework requirements, push your work to GitLab. Remember to create small incremental improvements with Git commits — you may like to refer to Rob Stewart's Introduction to Git video for the lifecycle of files in a Git repository. When you push your commits, GitLab will check that your file can be compiled.
Test dataset
A collection of PPM image files for you to test your steganography program with is available from Canvas, under Course Information > Assessment.
You may notice some PPM files in this collection have a new line after every colour value, whilst others have the R, G and B values for a pixel on one row.