Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

assembly language using visual studio 2010

This program demonstrates simple Symmetric-key Encryption using the XOR instruction with a multi-byte key entered by the user. Use this key to encrypt and decrypt the plain text as shown below (try ch06_08.exe):

C:\zdsite\fullcoll\fc241\files>ch06_11
Enter the plain text: This is a string.
Enter the encryption key: 12345
Cipher text: eZZG§XA?U§BFA][V?
Decrypted: This is a string.

C:\zdsite\fullcoll\fc241\files>ch06_11
Enter the plain text: This is a string.
Enter the encryption key: 1
Cipher text: eYXB?XB?P?BECX_V?

Decrypted: This is 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 directly reference to the buffer variable, to make it reusable and you can call it twice to receive the plain text and the multi-byte key like this:
.data
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
main11 PROC
mov edx,OFFSET prompt1 ; display buffer prompt
mov ebx,OFFSET buffer ; point to the buffer
call InputTheString
mov bufSize,eax ; save the buffer length

mov edx,OFFSET prompt2 ; display key prompt
mov ebx,OFFSET keyStr ; point to the key
call InputTheString
mov keySize,eax ; save the key length

A better alternative to using keySize is to keep checking the zero terminator in TranslateBuffer, since ReadString automatically adds a terminator to the end of keyStr.

As for TranslateBuffer PROC, the new logic could be similar to this:
Initialize ESI and EDI to point the message and key buffer memory
Make a loop for each byte in the message
Translate a message byte by XOR with a key byte
Update ESI for next char in message
Check if all key bytes used up?
If yes, reset EDI to point the key start byte
If no, Update EDI for next byte in key
Loop continuing
Return

Advanced discussion: A possible issue is display of the Cipher text that might result in some control chars, like zero, ODh, OAh, etc. One choice is to show an encoded char's ASCII code if it below or equal to a space (20h):
Enter plain text: LvAKabc
Enter your key: AAAAA22222
Cipher text: [0D]7[00][0A][20]PQ
Decrypted text: LvAKabc
Press any key to continue...

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91420773
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Computer Engineering

The question is asking how to do it in linuxa scientist ran

The question is asking how to do it in Linux. A scientist ran an experiment that generated data that accumulated in a sequence of files: data1, data2, data3, data4 and data5. He wants to know how many lines of data he ha ...

Please discuss the design principles that guide the authors

Please discuss the design principles that guide the authors of instruction sets in making the right balance. Provide examples of application of each of the three design principles while designing instruction sets.

Should you perform a log transformation on a categorical

Should you perform a log transformation on a categorical (nominal) variable, or can you only do that for continuous variables?

Question suppose the array begins with 0 followed by the

Question : Suppose the array begins with 0, followed by the remaining even integers in descending order, followed by the odd numbers in descending order. (For n = 8, the array would be [0,8,6,4,2,7,5,3,1].) How many comp ...

A series of information frames with a mean length of 100

A series of information frames with a mean length of 100 bits is to be transmitted across the following data links using an idle RQ protocol. If the velocity of propagation of the links is 2 * 10 8 ms -1 , determine the ...

We say that a binary tree t is perfectly balanced if for

We say that a binary tree T is perfectly balanced if, for each node n in T , the number of keys in the left and right subtrees of n differ at most by 1. Write an algorithm called Is-Perfectly-Balanced that, given a binar ...

Suppose that in responding to interrupts from io devicea

Suppose that in responding to interrupts from I/O deviceA the processor consumes 1000 cycles to perform the context switch required to transfer control to the interrupt handler. The interrupt handler takes an additional ...

Assume the following information for an imaginary closed

Assume the following information for an imaginary, closed economy. GDP = $100,000; taxes = $22,000; government purchases = $25,000; national saving = $15,000. Refer to Scenario 26-1.  For this economy, investment amounts ...

Question part 1 answer below question with atleast 350

Question: Part 1: answer below question with atleast 350 words in APA format no plagrism and also I need two professional refrences 1) What is the power of scenario planning Part 2: answer below question with atleast 350 ...

Push technologythis week covered the emerging trends and

Push Technology This week covered the emerging trends and technologies that may affect businesses as well as consumers. The increase in physiological interaction is another trend that may change how businesses and consum ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As