Program demonstrates simple symmetric-key encryption

Assignment Help Computer Engineering
Reference no: EM13850997

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...

Reference no: EM13850997

Questions Cloud

Dataset that can be used with the between subject design : Create a new dataset that can be used with the between subject design. You will no longer need the variables CreativePre and CreativePost Test. Instead, you will have only one variable for the score on the creativity test.
Analyze and discuss the failure and apply the laws : Analyze and discuss the failure and apply the laws given in the text showing clearly how the application of the laws might have lessened or even prevented the failure.
Closing case- china limits exports of rare earth materials : Closing Case- China Limits Exports of Rare Earth Materials. Which group benefitted the most from China imposing an export quota on rare earth metals? Did it give the Chinese domestic manufacturers a significant cost advantage
The issue of the us government using technology to spy : Create your blog on the issue of the US government using technology to spy on US citizens and/or foreign nations. Remember, your article must contain an author and a date AND be from the past 12 months.
Program demonstrates simple symmetric-key encryption : 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
Design a modern network for a private high school : Design a Modern Network for a Private High School. The network is proposed to achieve the above objectives considering the school's following business and technical goals.
Implementing a new performance appraisal system : Topic: An integrative approach to managing people issues arising from implementing a new performance appraisal system. Question: You are the team leader of an organisational and development unit within a human resources department of a large univer..
Calculate the value of this estimate for the sample : What is the unbiased estimate of the difference in height between boys and girls? Provide a formula and check the unbiasedness. Calculate the value of this estimate for the given sample.
How does the magnitude of electric force : How does the magnitude of electric force compare between a pair of charged particles when they are brought to half their original distance of separation? To one-quarter their original distance? To 4 times their original distance? (What law guides you..

Reviews

Write a Review

Computer Engineering Questions & Answers

  Find an instance method whenever the method is called

A ____ reference is an automatically created variable that holds the address of an object and passes it to an instance method whenever the method is known.

  How to generate a class diagram for the entity classes

How to generate a class diagram for the entity classes

  Write the expression for the charge on the capacitor plate

At time t=0 the capacitor is charged to 200uC,and the current is 0,write the expression for the charge on the capacitor s plate as the time function ?

  Process seteditable is a jtextcomponent method

Menus require a JMenuBar object so they can be attached to a JFrame.

  Make a class named order that performs order processing

build 4 Order class fields: order number, customer name, quantity ordered, and total price. Create public accessors for each field except total price.

  Write down code to complete the conversion

Include a Reset button, which will clear the interface controls.Write down code to complete the conversion.

  Define the context in which normalization is used

define the context in which Normalization is used. What is its purpose.

  What are the trends towards marrying

express at least two different ways that database management software like Microsoft® Access® can help an organization avoid or reduce data-quality problems mentioned in the article.

  Identifying and explaining the key components of a

identifying and describing the key components of a comprehensive disaster recovery plan for any incident that could

  Generating the printstream object

Generate a PrintStream object utilizing the dos and allocate the resulting reference to ps, a PrintStream variable which has already been declared.

  When is a good time to utalize a frame

can the information in the frames have been better presented in a table or links rather than a frame.

  Which there are 200 total unites available in the system

A system has five active processes(A-E) and one type of resource, that there are 200 total unites available in the system. the current state of the system is shown in the table below.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd