com-231
February 28, 2021
what is the pH of a solution made by adding water to .015 moles of HI untill the volume is…
February 28, 2021

assembly language

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:zdsitefullcollfc241files>ch06_11_x000D_
Enter the plain text: This is a string._x000D_
Enter the encryption key: 12345_x000D_
Cipher text:         eZZG§XA‼U§BFA][V∟_x000D_
Decrypted:           This is a string._x000D_
_x000D_
C:zdsitefullcollfc241files>ch06_11_x000D_
Enter the plain text: This is a string._x000D_
Enter the encryption key: 1_x000D_
Cipher text:         eYXBâ—„XBâ—„Pâ—„BECX_Vâ–¼_x000D_
Decrypted:           This is a string._x000D_

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_x000D_
prompt1  BYTE  "Enter the plain text: ",0_x000D_
prompt2  BYTE  "Enter the encryption key: ",0_x000D_
sEncrypt BYTE  "Cipher text:         ",0_x000D_
sDecrypt BYTE  "Decrypted:           ",0_x000D_
_x000D_
keyStr   BYTE   BUFMAX+1 DUP(0)_x000D_
keySize  DWORD  ?_x000D_
buffer   BYTE   BUFMAX+1 DUP(0)_x000D_
bufSize  DWORD  ?_x000D_
_x000D_
.code_x000D_
main11 PROC_x000D_
    mov edx,OFFSET prompt1  ; display buffer prompt_x000D_
    mov ebx,OFFSET buffer   ; point to the buffer_x000D_
    call InputTheString_x000D_
    mov bufSize,eax         ; save the buffer length_x000D_
_x000D_
    mov edx,OFFSET prompt2  ; display key prompt_x000D_
    mov ebx,OFFSET keyStr   ; point to the key_x000D_
    call InputTheString_x000D_
    mov keySize,eax         ; save the key length_x000D_
_x000D_
    ... ..._x000D_

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_x000D_
Enter your key:   AAAAA22222_x000D_
Cipher text:  [0D]7[00][0A][20]PQ_x000D_
Decrypted text:   LvAKabc_x000D_
Press any key to continue..._x000D_

 

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.