Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assembly Language: Using the following code template, also available in your examples directory downloaded with the Irvine code, encrypt a string representing your last name

Assembly Language:

Using the following code template, also available in your examples directory downloaded with the Irvine code, encrypt a string representing your last name and decrypt it back. Upload the zipped .asm file and the listing file of your code.

Top of Form

Flag this Question

Question

; Encryption Program (Encrypt.asm)

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

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 ; ; Prompts user for a plaintext string. Saves the string ; and its length. ; 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 ; ; Displays 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 encryption key byte. ; 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

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

Development Of Knowledge Framework For Affective Content Analysis

Authors: Swarnangini Sinha

1st Edition

B0CQJ13WZ1, 979-8223977490

Students also viewed these Databases questions

Question

What are your strengths when sending messages?

Answered: 1 week ago