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]
3 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]3 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
If the user enters 26 what is output? _____________
MArishka [77]

Please write the whole question, is it asking for the function that requests user input?

3 0
3 years ago
What is the purpose of requirements gathering
inn [45]

Answer:

to determine customer needs for a software

application

to reduce over scheduling of project

resources

Explanation:

Requirement gathering and analysis involves a business analyst and the client. And this is done in various phases with the first phase involving the business analyst and the client. And the second phase of software requirement is also being covered, and that is done by a team of System analysts, business analyst, and technical writers are part of both the team. However, both the phases have nothing to do with the bugs, and hence the first and the third part is not the correct part. However, customer needs are noted down, and in the second phase when resource requirement other than technical requirement is studied, partly it is ensured that there is no over the scheduling of the project resources during the project. And hence the second and the fourth options are the correct options.

3 0
3 years ago
Read 2 more answers
You're the administrator for a large bottling company. At the end of each month, you routinely view all logs and look for discre
Natali [406]

Answer:

It seems as though it would be a DDoS attack.

Explanation:

The characteristics are as follows:

A slow down of operations and attempting to get access into said service.

4 0
3 years ago
Will Give Brainliest
DENIUS [597]

Answer:

I would think Creativity, but im not sure-

6 0
3 years ago
Super computer in nuclear energy ​
satela [25.4K]

Answer:

Dubbed “El Capitan,” the supercomputer is part of the Exascale Computing Project, a DOE effort to increase computing power so that the department can run highly advanced simulations and modelling of the United States' nuclear arsenal. These simulations help alleviate the need for underground testing.

4 0
3 years ago
Other questions:
  • PriQueue inherits from Queue. In the implementation of the getMax() method in the PriQueue class, we need to read and write the
    5·1 answer
  • After installation of SSL certificate website asking for username and password.
    6·1 answer
  • When is a chart legend used
    8·2 answers
  • Look at the following program and answer the question that follows it. 1 // This program displays my gross wages. 2 // I worked
    8·1 answer
  • Function of an actuator
    8·2 answers
  • What is combo chart ? how will you created a combo chart​
    11·2 answers
  • How do cybercriminals use JavaScript maliciously?
    11·1 answer
  • Vocational counselors group career and occupation specialties into <br> career clusters.
    12·1 answer
  • Hi I'm new here can everyone add me as frein ​
    8·1 answer
  • When users connect to the network, they use a basic hardware terminal to access a desktop hosted on a virtualization server. wha
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!