Computer Engineering Department

Term 022

 

COE 205

 

Assembly Language & Computer Architecture

 

Lab Project

Encryption and Decryption of text files

  

Introduction:

The primary objective of this project is to see how much knowledge in assembly language programming the student has gained during the whole term.

 

However, the main objectives intended after this project may be summarized as:

 

1-     Review of most of 8086 assembly language taken in COE 205.

2-     String Manipulation

3-     Use of filing

4-     Structured programming using procedures and Macros.

 

References:

1.      Textbook, lecture notes and lab manual.

2.      Assembly Language Programming and Organization of the IBM PC, Ytha Yu and

Charles Marut, McGraw Hill, 1992.

3.      Randall Hyde, “The Art of Assembly Language Programming”,

http://webster.cs.ucr.edu/Page_asm/ArtofAssembly/0_ArtofAsm.html

 

Project Work:

Any useful information regarding the project will be put on the following link:

 

http://www.ccse.kfupm.edu.sa/~shazli/COE205/Project.htm

 

In this project, you are required to write a program that is able to encrypt and then decrypt a given text file. Lab experiments related to arithmetic and logical instructions should constitute the starting point for your project.

 

The program starts by displaying a menu that contains the following options:

 

1.      Encrypt a file

2.      Decrypt a file

3.      Exit.

 

Design and presentation of the menu are left for the programmer. Bear in mind that the menu should be interactive and easy to use. The use of a graphics menu and the mouse as a pointing and interfacing device is appreciable and will give you Bonus points.

 

Fig 1

 

An 8-bit Linear Feedback Shift Register (LFSR) is guaranteed to generate a random sequence in the range from 1 to 255 before it repeats again. The register has to be initialized first by a seed, which can be any number other than 0. An example of an LFSR is shown in Fig 1.

 

The choices in the menu are processed as explained below:

Choice 1:

The program should ask the name of the text file to encrypt.

The encryption algorithm is as follows:

1. Read a single character from the file.

2. Write a subroutine, RANDOMIZE, that implements a pseudo random generator, like the one mentioned above. Every time RANDOMIZE is called, it returns a new random number. The seed should be initialized outside the subroutine only once. The Random number generator shown in Fig 1 is given as an example.

3. Each character is encrypted by XORing the least significant 4-bits of the ASCII code of the character with the least significant 4 bits of the generated random number.

4. Convert the XOR'd value to a two-character ASCII string that contains the hexadecimal representation of that value.  For example, assume the character to be encrypted is A=41H and the random number is AAH. Then, the encrypted ASCII string will be 4BH

5. Swap the two characters and write them to the output file. E.g., "4B" would be written to the file as "B" followed by "4".

 

You can come up with your own encryption algorithm and earn a Bonus.

The program should write the encrypted characters to another file which should have the same file name as the original file but with the extension .coe

 

 

Choice 2:

The program should ask the name of the file to decrypt. It should give an error message if the extension of the file name entered is not .coe

It should then decrypt the file. The decryption does the reverse of the above and will restore the original characters. The decrypted characters should be written to another file with the same file name but with extension .txt

 

Choice 3:

The program simply exits to the main menu

 

 

Guidelines:

Make your program well structured, using procedures and MACROs. Put all your MACROs in a separate file and include at the beginning of your program. Use comments as much as you think this will make your program understandable, and separate your procedures by such comments. Make your program interactive, in the sense that it is user-friendly.  The use of different colors for different options is appreciated. You can get the information regarding writing to or reading from a file in the references given.

 

At the end of your work submit a hard copy and a soft copy of your program, including both source and executable files on a floppy disc.

 

Policy on Academic Dishonesty: 

Almost all computer programs contain many ideas borrowed from elsewhere, however, copying code from other people or from books won't teach you how to program. To learn programming, you must learn to solve your own programming problems.

·        You are not allowed to copy code from other students (or former students).  Possession of source code belonging to another student is an academic offence, with penalties for everyone involved, both the author and the recipients.

Your instructor will be sympathetic to the students who try to accomplish the tasks, but in the end are not able to furnish a working program, however, you will be given a ZERO in the project if any dishonesty is found on your part.

 

Hints:

To be able to complete the project start using a simple approach, and fix yourself very simple targets that you should achieve first. Then build upon the program you have written, and keep all the modified versions of your program by giving them names that should be meaningful, like pgm1ver1.asm or p11.asm for program 1 version 1 …. Submit only the last version that contains the finalized work, and any attached files like the MACRO file.

 

Bonus:

You will get a 10% Bonus if you use graphics and mouse. A 5% bonus will be given if you come up with your own encryption algorithm which should be hard to break.

 

Project Submission:

You have around 4 weeks to work on the project. You can work in groups of two. The projects should be submitted between 31st May and 4th June 2003. The sheets showing the empty slots will be posted outside the office of your instructor. Fill in the appropriate time slot and come on time with the required material. Both the students should be present at the time of project submission.

 

 

 

 

 

 

 

Marks Distribution:

The project counts for 50% of the lab, i.e. 10% of the course, and is marked as follows:

 

Section

Mark

Clarity and Presentation

10

Use of Procedures

10

Use of Macros/Include File

10

Comments

10

Ease of Use

10

Encryption

25

Decryption

25

Total

100