UQ Students should read the Disclaimer & Warning
Note: This page dates from 2005, and is kept for historical purposes.
COMP2301 – Assignment Two – File I/O in C
This assignment is a pass/fail assignment. I achieved a pass.
The goal of this assignment is to write C code to perform a simple file encryption and decryption.
The solution must have the following features / functions:
- The application must encrypt any sample files for use as test input. Valid files include JPEG, ZIP, EXE, TXT, WORD...
- The first 30 bytes of the encrypted files must contain the source student name as clear text. (Max 30 char)
- The last 35 bytes of the encrypted files must contain an encrypted text version of source student name.
- The last five bytes of the encrypted file must contain a clear ASCII representation of original file size in bytes.
- Data must be encrypted by taking a binary representation of the key and performing a bit wise XOR with the original file binary then repeating the process with the next key length file segment until the file is encrypted.
- A unique five digit hexadecimal key will be supplied with each encrypted sample file.
- The application must decrypt at least 10 unique sample files obtained from 10 different individuals. (+10 unique keys)
- The application must decrypt any sample file provided by a tutor during marking.
- The application must generate a text menu showing all input files (max 20) and allow the user to select one file
- This menu must include file selection number, source name, original file size and encrypted file size (Max 20 files)
- After file selection the user must be prompted for a five digit hexadecimal decryption key.
- The key is to be applied to the encrypted file to restore its original content.
- In addition to decrypting the file content the original file structure and size must be restored. The application must display start and end messages plus include the following strings <source name> = <decoded source name> is [True| False] Original file size <nnnnn> = decrypted file size <nnnnn> is [True| False]
- Encryption Key is [Valid | Invalid]
- The application must provide a simple text menu system to navigate its functions.
- Code may use C library functions.
- Code must be modular and make good use of C functions.
- Code comments must correctly reference the work of others.
- Code must be readable, well structured and conform to the pre-defined style guide
The most complex part of this assignment, for me, was the creation of the key. I ended up using the technique below:
Code © Copyright 2004 Ned Martin