This program is intended to provide experience in dealing with the array data structure.
Write a SASM program that encrypts a user-entered string using a user-entered key (required algorithm is given below).
A sample execution of the program looks like
Enter key: abcde
Enter plain text:
coastisclear
Encrypted:
cpcvxiteoias
Use the encryption algorithm that was state-of-the-art in the mid 1800s. Consider each letter (of plain text, of the key, and of encrypted text) to be an integer, where a=0, b=1, and z=25. An encrypted character is defined to be the sum of a plain text character and a key character modulo 26.
Since the key can be shorter than the plain text, the key is repeated as many times as needed.
An example, with a key of great
:
key (repeated) g r e a t g r e a t key value 6 17 4 0 19 6 17 4 0 19 plain text h e l l o w o r l d plain text value 7 4 11 11 14 22 14 17 11 3 sum 13 21 15 11 33 28 31 21 11 22 sum mod 26 13 21 15 11 7 2 5 21 11 22 encrypted text n v p l h c f v l w
Follow the guidelines in
how to turn in assignments.
For this program, you will need to turn in your source code
(the .asm
extension) and your makefile
(the .mak
extension).
No printout will be turned in.
01001100 + 11111110 ---------- 11101100 - 10010100 ---------- 01101100 x 10000100 ----------
xx
if the corresponding bit of
variable yy
is cleared.
Assume that bits are numbered from the right starting with 0.
Follow the guidelines in
how to turn in assignments.
For this homework, you will need to turn in a single
file containing your answers to the homework questions.
To make grading easier, please name your file hw2.txt
.
No printout will be turned in.