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 a work is in the public domain… Group of answer choices its copyright has expired. it may not be used for commercial purposes
ArbitrLikvidat [17]

Answer:

its copyright has expired

Explanation:

If a work is in the public domain it means that it's copyrighte has been expired.

After the period of copyright protection has expired, a work becomes available for use without permission from the copyright owner; it is now said to be  "in the public domain." Most works enter the public domain because their copyrights have expired.

3 0
3 years ago
For a web application we associate a web server, for a mobile application we associate a mobile server. for a decentralized appl
Alex_Xolod [135]

For a decentralized software application we associate a blockchain server.

<h3>What is a server?</h3>

A server can be defined as a dedicated computer system that is designed and developed to provide specific services to other computer devices or programs, which are commonly referred to as the clients.

<h3>Types of server.</h3>

In Computer technology, there are different types of server and these include the following:

  • Web server
  • Email server
  • File server
  • Database server
  • Proxy server
  • Distributed communication server
  • Centralized Server
  • Distributed application server
  • Blockchain server

Generally, a web software application is associated with a web server, a mobile software application is associated with a mobile server, and a decentralized software application we associate a blockchain server.

Read more on web server here: brainly.com/question/27960093

#SPJ1

7 0
1 year ago
What is Patch tool ???<br><br>​
AfilCa [17]

Answer:

<u><em>DEAR HERE IS YOUR ANSWER:</em></u>

<u><em>T</em></u>he Patch Tool is part of the healing brush set of tools. These are the go-to tools for retouching and repairing your images. The Patch Tool is primarily used to repair larger areas of an image, or get rid of any distractions or blemishes.

  • The patch tool was introduced into Photoshop at the same time as the Healing Brush
  • You don’t have to use the Patch tool to define a selection. You can use any selection tool and then select the Patch tool.  <em><u> </u></em>

<em><u>HOW TO USE PATCH TOOL IN PHOTOSHOP:</u></em>

  1. Click and hold the Healing Brush tool to select the Patch tool; on the Options bar, select the Destination radio button
  2. With the Patch tool still selected, drag to create a marquee around the source you want to use as the patch
  3. After you create the marquee, drag the selected source area to the destination to be repaired.

<em><u>I HOPE IT WILL WORK DEAR THANKS FOR ASKING  QUESTION</u></em>

Explanation:

4 0
3 years ago
Read 2 more answers
You can create a ____ partition to hold files that are created temporarily, such as files used for printing documents (spool fil
Lisa [10]
/var is the answer to then empty space
3 0
3 years ago
What is a tax exemption (also known as a tax allowance)?
KengaRu [80]
<span>Tax exemption refers to a monetary exemption which reduces taxable income. Tax exempt status can provide complete relief from taxes, reduced rates, or tax on only a portion of items.</span>
4 0
3 years ago
Other questions:
  • The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.
    7·1 answer
  • What type of survey can help a network administrator make decisions about bands, channels, and widths when installing new access
    9·1 answer
  • The United States is the only country in the world in which organs and tissue transplants are performed. True or False?
    8·1 answer
  • What’s the best description of an opportunity cost
    5·1 answer
  • Vhich economic impact of computers was mentioned in this lesson?
    6·1 answer
  • The memory unit of a computer has 2M Words of 32 bits (or 4 bytes) each. The computer has an instruction format with 4 fields: a
    14·1 answer
  • What does Putting a word in quotation marks on your search bar do on google?
    12·1 answer
  • What is the codebook?
    6·1 answer
  • Alfred works in the human resources department, and he uses a management information system to find applicants' résumés on the w
    7·1 answer
  • Please answer this question​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!