Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MASM Assembly Programming Language May use Irvine32.inc library, please leave comments, must be in MASM x86 Assembly language. Thank you in advance! Below is teacher's

MASM Assembly Programming Language

May use Irvine32.inc library, please leave comments, must be in MASM x86 Assembly language. Thank you in advance!

Below is teacher's given encryption file(.asm) as a template:

*********************************

TITLE Encryption Program (Encrypt.asm)

; This program demonstrates simple symmetric ; encryption using the XOR instruction. ; Chapter 6 example.

INCLUDE Irvine32.inc

KEY = 239 ; any value between 1-255 BUFMAX = 128 ; maximum buffer size

.data sPrompt BYTE "Enter the plain text: ",0 sEncrypt BYTE "Cipher text: ",0 sDecrypt BYTE "Decrypted: ",0

buffer BYTE BUFMAX+1 DUP(0) bufSize DWORD ?

.code main PROC

call InputTheString ; input the plain text call TranslateBuffer ; encrypt the buffer mov edx,OFFSET sEncrypt ; display encrypted message call DisplayMessage call TranslateBuffer ; decrypt the buffer mov edx,OFFSET sDecrypt ; display decrypted message call DisplayMessage

exit main ENDP

;----------------------------------------------------- InputTheString PROC ; ; Asks the user to enter a string from the ; keyboard. Saves the string and its length ; in variables. ; Receives: nothing. Returns: nothing ;----------------------------------------------------- pushad mov edx,OFFSET sPrompt ; display a prompt call WriteString mov ecx,BUFMAX ; maximum character count mov edx,offset buffer ; point to the buffer call ReadString ; input the string mov bufSize,eax ; save the length call Crlf popad ret InputTheString ENDP

;----------------------------------------------------- DisplayMessage PROC ; ; Display the encrypted or decrypted message. ; Receives: EDX points to the message ; Returns: nothing ;----------------------------------------------------- pushad call WriteString mov edx,OFFSET buffer ; display the buffer call WriteString call Crlf call Crlf popad ret DisplayMessage ENDP

;----------------------------------------------------- TranslateBuffer PROC ; ; Translates the string by exclusive-ORing each byte ; with the same integer. ; Receives: nothing. Returns: nothing ;----------------------------------------------------- pushad mov ecx,bufSize ; loop counter mov esi,0 ; index 0 in buffer L1: xor buffer[esi],KEY ; translate a byte inc esi ; point to next byte loop L1

popad ret TranslateBuffer ENDP END main

************************************

image text in transcribed

Assignment A Use the instructor given example (Encrypt asm as the template for your program code. Program Description You program will ask the user to enter a. A key of length 1 to 10 character(s) b. A file-name to be (read and) encrypted. Once you get the key and the file-name of an existing file, a. you will need to open the file if exists (else inform that the file does not exist, b. you will need to read the content of file in a buffer, c. using the key encrypt the content by applying XOR operation, d. create a new file, name it En file-name', write/place the encrypted content into the En file-name file, f. close the En file-name file, and g. inform the user that the task has been (successfully done. The user will be able to get the content of the file-name file back in En En file-name file by re- running your program on En file-name file with the same key supplied, if your program is correctly working. You are allowed to use the author's (Irvine) functions/procedures see chapter 5) such as CloseFile, CreateOutputFile, OpenInputFile, ReadFromFile, WriteToFile, etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions