MASM: Assmebly Language for x86 Processors. Hello chegg experts, I desperately n
ID: 3590419 • Letter: M
Question
MASM: Assmebly Language for x86 Processors.
Hello chegg experts, I desperately need your help on my 32 bit programming assignment.
Here is the assignment,
Multiple_Byte_Key_Encryption :
Please!!
Thank you in advance...
Multiple_Byte_Key_Encryption (Chapter 8, Pr 8, Modified) This program demorstrates simple Symmetric-key Encrypt an using the XOR irstruction with a multi-byte key entered by the user. Use this key to encrypt and dec typt the plain text as shown below (try ch05_08.exe) Enter the plain text: Tiis 1s a string Entere encryption key: 12345 Cipher text: Th18 1 string Bnter the enryption key 1 Cipber text: Decrypted: This 1s a string You can use the sample Encrypt.asm as a start point. With a multi-byte key, you have to modify the procedure TranslateBuffer Also, modify InputTheString without cirectly reference to the bufer variable, to make it reusable and you can call it twice to receive the plain text and the mult-byte key like this. da ta prompt1 BYTE "Enter the plain text: 0 : promp12 YTL "nter the encryption key: ",O sEncrypt BYTE "Cipher text: : aDecrypt BYTE "Decrypted: keys1ze DMORD ? bursizA DWORD? nainl1 FROC nov edx,OPPSET pronpti diaplay buffer pronpt mov ebx,OPPSET bufer point to the buffer oall InpatTbestring save the buffer iength: nov edx, OPPSET pronpt.2display key pronpt mov ebx, OFESET keystr point to tbe key call InpatThestring mov keysize,eax : save the key lenqthExplanation / Answer
INCLUDE Irvine32.inc
.data
BUFMAX = 125
prompt1 BYTE "Enter the plain text : ",0
prompt2 BYTE "Enter the encryption key : ",0
sEncrypt BYTE "Cipher text : ",0
sDecrypt BYTE "Decrypted : ",0
keyStr BYTE BUFMAX + 1 DUP(0)
keySize DWORD ?
buffer BYTE BUFMAX + 1 DUP(0)
bufSize DWORD ?
.code
main PROC
mov edx, OFFSET prompt1 ; display buffer prompt
call WriteString
mov edx, OFFSET buffer ; point to the buffer
call InputTheString
mov bufSize, eax ; save the buffer length
mov edx, OFFSET prompt2 ; display key prompt
call WriteString
mov edx, OFFSET keyStr ; point to the key
call InputTheString
mov keySize, eax ; save the key length
call TranslateBuffer ; encrypt
mov edx, OFFSET sEncrypt ; display sEncrypt
call WriteString
mov edx, OFFSET buffer ; display ciphred string
call WriteString
call TranslateBuffer ; decrypt
call crlf
mov edx, OFFSET sDecrypt ; display sEncrypt string
call WriteString
mov edx, OFFSET buffer ; display deciphered string
call WriteString
call crlf
;call WaitMsg ; display wait message
;This is a string.
main ENDP
;-------------------------------------------------------------------
InputTheString PROC
;-------------------------------------------------------------------
mov ecx, BUFMAX ; read maximum of BUFMAX character long string
call ReadString ; read the string from the user
ret
InputTheString ENDP
;-------------------------------------------------------------------
TranslateBuffer PROC
;-------------------------------------------------------------------
mov ecx, bufSize ; loop until end of the string
mov esi, 0 ; starting index 0 for buffer
mov edi, 0 ; starting index 0 for keyString
L1:
mov al, keyStr[edi] ; store the first keyString letter in dl and
xor buffer[esi], al ; XOR with the buffer's first letter and store it in buffer
inc esi ; increment buffer's index
inc edi ; increment keyStr's index
cmp edi, keySize ; compare EDI & keySize
jl continue_loop ; jump if less than keyStr
mov edi, 0 ; otherwise reset the keyString index
continue_loop:
loop L1 ; and continue loop
ret
TranslateBuffer ENDP
END main
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.