Documents
User Generated
Resources
Learning Center

# Hmwk1-F10

VIEWS: 4 PAGES: 3

• pg 1
```									                                          CpE390 Homework 1 - Fall 2010
Caesar Cipher
(Tewksbury)

IMPORTANT REQUIREMENT
You are REQUIRED to submit this cover page, completed with the date submitted to
Elearn/WebCT and your name. Submissions not complying will be given a grade of 0. By adding
your name, you are pledging that you have obeyed the Stevens' Honor Code in the development of
your solutions (i.e., you are pledging that the solutions submitted were developed by you and
represent your understanding of the topics involved). I am particularly sensitive to copying of
another person’s work - and do report to the Honor Board cases suggesting that copying has been
done.
Date Submitted:
Name

RULES FOR SUBMISSIONS
     All homework must be both
o      Submitted and demonstrated to your CpE390 Lab instructor and
o      The report must be uploaded to the Elearn site for CpE390. Scanned copies of
handwritten solutions may be penalized (they can be very hard to read).
     A sufficient number of screen shots should be included in your submission to demonstrate
that the program successfully built and ran.

CONTENTS

1. BACKGROUND .....................................................................................................................................................1

2. HOMEWORK QUESTIONS .................................................................................................................................2
PROBLEM 2.1 ENCRYPTION OF BOTH LETTERS AND NUMBERS..................................................................................2
PROBLEM 2.2 DE-ENCRYPTION OF TEXT FILE WITH ENCRYPTED LETTERS (NUMBERS NOT ENCRYPTED) ................3

1. Background
In class, we discussed a version of an assembly language program that encrypted text that had been input
by the user. The encryption shifted the letters ‘a’ - ‘z’ and ‘A’ - ‘Z’ by some integer number of places,
with letters rotating back to the first letter of the set (‘a’ or ‘A’, depending on the case of the letter).
There are 26 letters in each set (26 lower case and 26 upper case). If a lower case (upper case) letter after
being shifted is found to have an ASCII binary code greater than that of ‘z’ (‘Z’), then subtraction of 26
from that ASCII code implements the wrap around. It was also noted that if the shift amount S is greater
than 26, then repeated subtractions of 26 from S until the resulting number is in the range 0 to 25 leads to
an equivalent shift S’. If the shift S is already in the range from 0 to 25, then S’ = S.
The Week 4 weekly notes (under Weekly on the course details main page) include the program discussed
in class and the more detailed principles of the Caesar Cipher problem from the perspective of the C++
programming language.

2. Homework Questions
Each of the following two questions, one concerned with encryption of numbers as well as letters and the
other concerned with de-encryption (letters only) a text file when you know the Caesar Cipher offset,
counts for 50% of the grade.

Problem 2.1 Encryption of Both Letters and Numbers
Using the program example in class (or your own program to encrypt letters in text files), extend the
program to encrypt the numbers 0 through 9 as well as the letters ‘a’ through ‘z’ and the letters ‘A’
through ‘Z’.
The letter sets (lower case and upper case) each contain 26 letters, leading to the use of the number 26 in
the background discussion above to obtain an equivalent shift S’ for the letters and to execute the wrap
around of letters from ‘z’ (‘Z’) to ‘a’ (‘A’). There are 10 numbers - ‘0’, ‘1’, ‘2’, ....’9’. Consider whether
this requires a different equivalent shift and wrap-around correction for numbers. Should the Caesar shift
entered for letters (and reduced to a number between 0 and 25) be reduced to a number between 0 and 9
when applied to numbers??
The ASCII codes needed (in order from smallest to largest binary number) are as follows
‘0’          ‘9’           ‘A’           ‘Z’          ‘a’           ‘z’
ASCII            \$30           \$39           \$41          \$5a           \$61           \$7a
CODE

Submission Instructions - Prob 2.1: Both of the following are REQUIRED.
Submission via uploading to Elearn a formal report (MS Word or PDF) including:
1. The assembly language program written (copy the assembly language program from the
MiniIDE assembler and paste into your report - do not include the actual .asm program file).
Do NOT use a screen shot to display your program - it is hard to read at my end.
2. A screen shot showing successful build of your program using the MiniIDE assembler
environment.
3. A screen shot showing the successful running of the program in the JAVA simulator (window
showing registers, memory locations, etc).
4. A screen shot of the SCI viewer window showing
 The offset entered by the user.
 The text textin entered by the user.
o The text textenc generated by the encryption part of the program.

Submit to CpE390 Lab instructor including
1. A copy of your above report to the CpE390 Lab instructor and
2. A demonstration of successful operation of your program to the CpE390 Lab instructor.
Problem 2.2 De-Encryption of Text File With Encrypted Letters (Numbers not Encrypted)
The starting program for problem 2.1 above was the program discussed in class to encrypt letters in a text
textin entered by the user, applying the Caesar cipher offset also entered by the user to generate the
encrypted text textenc. This problem involves adding, to the end of this starting program, instructions
that will de-encrypt the encrypted text textenc using the same Caesar cipher offset as for the encryption.
The text file generated by the de-encryption should be stored in textdc.
The general structure of your extended program will be as shown below. Your new program de-
encrypts ONLY letters. The blue lines represent the starting program for encryption of letters only. The
red lines are the new assembly language program lines you will be adding to de-encrypt the encrypted
text textenc.
*** Declarations of constants using EQU statements ******
EQU statements. (additions as needed)
*** Declarations of variables using DC.B and DS.B statements ******
DC.B and DS.B statements. (additions as needed)
*** Starting Program to Encrypt Letters of Text ******
Assembly language instructions
.......
*** END statement of starting program (remove it)
END
*** BEGINNING OF DE-ENCRYPT PROGRAM INSTRUCTIONS ******
Assembly language instructions
.......
*** END statement of new program (add it)
END

Submission Instructions- Prob 2.2: Both of the following are REQUIRED.
Submission via uploading to Elearn a formal report (MS Word or PDF) including:
1. The assembly language program written (copy the assembly language program from the
MiniIDE assembler and paste into your report - do not include the actual .asm program file).
Do NOT use a screen shot to display your program - it is hard to read at my end.
2. A screen shot showing successful build of your program using the MiniIDE assembler
environment.
3. A screen shot showing the successful running of the program in the JAVA simulator (window
showing registers, memory locations, etc).
4. A screen shot of the SCI viewer window showing
 The offset entered by the user.
 The text textin entered by the user.
 The text textenc generated by the encryption part of the program.
 The de-encrypted text textdc generated by the de-encryption part of the program
 Submit to CpE390 Lab instructor including
1. A copy of your above report to the CpE390 Lab instructor and
2. A demonstration of successful operation of your program to the CpE390 Lab instructor.

```
To top