Question
In this lab we will write an assembly program to encrypt message as follows: Let the user enter an encryption key consisting of multiple characters.
In this lab we will write an assembly program to encrypt message as follows:
Let the user enter an encryption key consisting of multiple characters. Use this key to encrypt and decrypt the user-entered plaintext message by XORing each character of the key against a corresponding byte in the message. Repeat the key as many times as necessary until all plaintext bytes are translated. Suppose, for example, the key equals ABXmv#7. This is how the key would align with the plaintext bytes:
T | h | i | s |
| i | s |
| a |
| p | l | a | i | n | t | e | x | t |
| m | e | s | s | a | g | E |
|
A | B | X | m | v | # | 7 | A | B | X | m | v | # | 7 | A | B | X | m | v | # | 7 | A | B | X | m | v | # | 7 |
(The key repeats until it equals the length of the plain text ...)
Please refer to the lecture slides for Chapter 6 for the example.
Your code should print out the original message, then the encrypted message, and then the decrypted message. To encrypt the message, you XOR the message and the key (as above). The decryption is the same as encryption, except you XOR the ciphertext and the key.
Hints:
You should use CALL ReadString to read in the message and key. For this procedure, EDX must contain the OFFSET where the data is stored, and ECX must contain the max number of non-NULL values. When finished, EAX will hold the length of the entered String.
See this page for more details on CALL ReadString: http://programming.msjc.edu/asm/help/source/irvinelib/readstring.htm
You should use the instruction XOR to perform your encryption. The syntax is similar to the ADD instruction.
BONUS (10 points):
Write your encryption/decryption portion of the code as a procedure that is called. If done properly, the same procedure should be used for both encryption and decryption.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started