1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gnesinka [82]
2 years ago
10

Encryption Using Rotate Operations Write a procedure that performs simple encryption by rotating each plaintext byte a varying n

umber of positions in different directions. For example, in the following array that represents the encryption key, a negative value indicates a rotation to the left and a positive value indicates a rotation to the right. The integer in each position indicates the magnitude of the rotation: key BYTE -2, 4, 1, 0, -3, 5, 2, -4, -4, 6
Computers and Technology
1 answer:
lesantik [10]2 years ago
8 0

Answer:

Check the explanation

Explanation:

1) Assembly language code for Encryption using rotate operations.

INCLUDE Irvine32.inc

INCLUDE Macros.inc

BufSize = 80

.data

  key BYTE 6, 4, 1, 2, 7, 5, 2, 4, 3, 6

  myText BYTE "This text is going to be encrypted.", 0

  buffer BYTE BufSize DUP(?),0,0

  stdInHandle HANDLE ?

  bytesRead DWORD ?

.code

main PROC

  ;Pass the pointer to the text string in EDX,

  MOV EDX, OFFSET myText

 

  ;the array size to ECX

  MOV ECX, SIZEOF myText

 

  ;pointer to the key array in ESI,  

  MOV ESI, OFFSET key

  ;the direction value (0 or 1) in EBX

  MOV EBX, 0 ; rotate left for encryption

  call WriteString

  call Crlf

  call encDecText

  call WriteString

  call Crlf

  MOV EBX, 1

  call encDecText

  call WriteString

  call Crlf

  ;bonus - get string from console and encrypt

  mWriteln "Write a text to be encrypted."

  ; Get handle to standard input

  INVOKE GetStdHandle, STD_INPUT_HANDLE

  mov stdInHandle,eax

  ; Wait for user input

  INVOKE ReadConsole, stdInHandle, ADDR buffer,

  BufSize, ADDR bytesRead, 0

  ;encrypt and output to console

  MOV EDX, OFFSET buffer

  MOV ECX, BufSize

  MOV EBX, 0

  call encDecText

  call WriteString

  call Crlf

  ;decrypt and output to console

  MOV EBX, 1

  call encDecText

  call WriteString

  INVOKE ExitProcess,0 ; end the program

main ENDP

encDecText PROC

  ;Receives EDX - OFFSET of the text

  ; ECX - SIZE of the text

  ; ESI - OFFSET of the key

  ; EBX - rotation direction 0 for left 1 for right

  PUSHAD

  CMP EBX, 0

  JE equals

      MOV EBX, ESI

      ADD EBX, 9 ;the length of key

      loopNotEquals:

      MOV AL, [EDX] ; value of the text

      PUSH ECX

      MOV CL, [ESI] ; value of the key

      ROR AL, CL ; ror the text by the key

      MOV [EDX], AL

      POP ECX

      CMP ESI, EBX ; if all the keys are used, reset the offset so it uses the beginning

      JE reset1

     

      INC ESI

     

      JMP endReset1

      reset1:

      SUB ESI, 9

      endReset1:

     

      INC EDX

      loop loopNotEquals

      mWriteln "Input decrypted."

  JMP endCMP

  equals:

      MOV EBX, ESI

      ADD EBX, 9 ; the length of key

      loopEquals:

      MOV AL, [EDX] ; value of the text

      PUSH ECX

      MOV CL, [ESI] ; value of the key

      ROL AL, CL ; rol the text by the key

      MOV [EDX], AL

      POP ECX

      CMP ESI, EBX ; if all the keys are used, reset the offset so it uses the beginning

      JE reset2

      INC ESI

     

      JMP endReset2

      reset2:

      SUB ESI, 9

      endReset2:

      INC EDX

      loop loopEquals

      mWriteln "Input encrypted."

  endCMP:

  POPAD

  RET

encDecText ENDP

END main

Save the files with .asm extension.

You might be interested in
Read the following scenario. How might Sarah correct successfully complete her task?
nexus9112 [7]

Answer:

Explanation:

A: To permanently remove a file from her computer, Sarah doubled-clicked on the My Computer icon and searched for her file under the “Uninstall or change a program” menu option.

or

b: empty the recycle bin : You can permanently delete a program file installed in the computer by following the procedure in option A. The option above will take you to the control panel and you'll be able to select the program you'd want to permanently remove. If you had initially deleted a file like a picture or a document or anything else that you necessarily do not need, it will go to recycle bin. You can head over there and select the Empty the Recycle Bin option to permanently delete the file.

4 0
3 years ago
To display or distribute information from a database, programmers or database administrators create ___ .
Rainbow [258]
The answer is Reports.  To display or distribute information from a database, programmers or database administrators create Reports.
3 0
3 years ago
LAB: Plant information (ArrayList) Given a base Plant class and a derived Flower class, complete main() to create an ArrayList c
sashaice [31]

Answer:

LAB: Plant information (ArrayList) Given a base Plant class and a derived Flower class, complete main() to create an ArrayList called myGarden. The ArrayList should be able to store objects that belong to the Plant class or the Flower class. Create a method called printArrayList), that uses the printinfo methods defined in the respective classes and prints each element in

4 0
3 years ago
Software licensed as proprietary
steposvetlana [31]

Answer:

Does not permit source code changes.

Explanation:

3 0
3 years ago
Read 2 more answers
What are characteristics of the Advanced Calendar options in Outlook? Check all that apply.
anzhelika [568]

Answer:

Free/busy settings can be enabled.

One extra time zone can be created.

Display and theme settings can be changed.

Options are accessed through the Backstage view.

Explanation:

Just took it

7 0
3 years ago
Other questions:
  • Although the original BBS system was simple, it increased people's ability to communicate
    14·1 answer
  • Replmon is the first tool you should use when troubleshooting Active Directory replication issues. State True or False.
    12·1 answer
  • Describe how to manipulate artwork in a presentation.
    13·1 answer
  • A single-user database system automatically ensures ____ of the database, because only one transaction is executed at a time.
    13·1 answer
  • Who created apple and in what year was it created
    9·2 answers
  • "What line of code can be used to provide a convenient way to merge the source code from one file with the source code in anothe
    8·1 answer
  • Do pc players ever go outside?
    11·2 answers
  • Create a program which reads in CSV data of Creatures and loads them into aHash Map. The key of this hash map will be the name o
    10·1 answer
  • QUESTION 10
    11·1 answer
  • Where are all my smart ppl at? Help me out!!!
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!