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
Given the following function definition
siniylev [52]

Answer:

B. 1 6 3

Explanation:

Given function definition for calc:

void calc (int a, int& b)

{

int c;

c = a + 2;

a = a * 3;

b = c + a;

}

Function invocation:

x = 1;

y = 2;

z = 3;

calc(x, y);

cout << x << " " << y << " " << z << endl;

  • Since x is passed by value, its value remains 1.
  • y is passed by reference to the function calc(x,y);

Tracing the function execution:

c=3

a=3

b=c+a = 6;

But b actually corresponds to y. So y=6 after function call.

  • Since z is not involved in function call, its value remain 3.

So output: 1 6 3

3 0
3 years ago
In what situations other than developing software might the process of analysis, design, development, test, deployment, and main
forsale [732]

In Systems development  or  traditional waterfall approach will the process of analysis, design, development, test, deployment, and maintenance be a useful approach.

<h3>What is software development?</h3>

Software development is known to be a term that connote the composition  of computer science works made for the process of developing , designing, and aiding software.

Note that In Systems development  or  traditional waterfall approach will the process of analysis, design, development, test, deployment, and maintenance be a useful approach. as it also uses the dteps listed above.

Learn more about software from

brainly.com/question/1538272

#SPJ1

7 0
2 years ago
What is the name and purpose of the star next to a slide in a PowerPoint presentation?
Finger [1]
If you observe closely, you may see that these stars are shown only against some slides and not all of them.

The stars are just an indication that the particular slide has custom animation. That was you can quickly see at a glance if a slide has content that is animated.

The same star symbol is also shown when the slide itself has any slide transition set.
7 0
2 years ago
Write a bool function isPalindrome that takes one string parameter and returns true if that string is a palindrome and false oth
kkurt [141]

Answer:

Here is the bool function isPalindrome:

bool isPalindrome(string s)

{  bool palindrome;      

 int j;

 int len = s.length();

 for (int i =0, j= len-1; i < len/2; i++, j--)  

   if (s[i] == s[j])

     palindrome = true;  

   else

     palindrome = false;

 return palindrome; }

Explanation:

The bool function isPalindrome takes a string as parameter and returns true if the string is a palindrome or false if the string is not palindrome. The string variable s holds the string value. In function isPalindrome, there is a bool type variable palindrome. bool is a data type which is used to hold values true or false which is then stored in the palindrome variable.

Next it is being found that how many characters are there in the input string using length() function which returns the length of the string. The length of the string is stored in int type variable len.

Next the for loop starts which has two variables i and j where i starts at 0 position of the input string and j starts at the last position of the string. These two variables move or traverse along the string this way. i variable stops when half the length of the input string is reached. At the end of every iteration i moves forward by the increment of its value to 1 and j moves backwards by the decrement  of its value to 1.

Every the body of  the loop executes, there is an if condition in the body of the loop which checks if the string is a palindrome. This is checked by matching the character at position/index i with the character at position j of the string. This will continue character by character until the i reached half the length of the input string and if every character in i was matched to every character in j then palindrome = true; statement is executed which returns true as the string is a palindrome otherwise palindrome = false; is returned as the string is not a palindrome.

For taking input string from the user and to check if the function isPalindrome() works correctly a main() function is written which takes input string from the user and reads in variable str calls isPalindrome() function. If the string is palindrome then the cout statement in main() function prints the message: String is a palindrome and if the input string is not a palindrome the the following message is displayed in the output screen: String is not a palindrome

int main()

{

string str;

cout<<"Enter a string: ";

cin>>str;

if(isPalindrome(str))

cout<<"String is a palindrome";

else

cout<<"String is not a palindrome";

}

The screenshot of the program along with the output is attached.

7 0
2 years ago
Yuki is preparing to write a research paper for his history class. Which style guide would be best for him to use?
FromTheMoon [43]
The answer is Modern Language Association (MLA).  Yuki is preparing to write a research paper for his history class. The style guide that would be best for him to use is Modern Language Association (MLA).  <span>MLA style is a system for documenting sources in scholarly writing.  it has been widely used for classroom instruction and used worldwide by scholars, journal publishers, academic and commercial presses.</span>
3 0
3 years ago
Read 2 more answers
Other questions:
  • The amount of interest you will earn in one year from a savings account is the _____. A) APY B) return C) IDA D) CD
    12·2 answers
  • To keep your audience interested in your speech, you should provide them with as many details as possible about the topic.
    12·1 answer
  • White meat and dark meat fish have slightly different nutritional characteristics. What are the nutrition characteristics of dar
    7·2 answers
  • An ironworker standing 30 feet in the air is safe wearing a full body harness that is not tied off
    15·2 answers
  • In order to get a comprehensive evaluation of the computer programmers he managed, Justin organized a(n) __________, where he as
    11·1 answer
  • The term phreaker is now commonly associated with an individual who cracks or removes software protection that is designed to pr
    13·2 answers
  • Write a small program that takes in two numbers from the user. Using an if statement and an else statement, compare them and tel
    12·1 answer
  • Write an algorithm to display your name 10 times​
    5·1 answer
  • In this lab, you complete a C++ program that uses an array to store data for the village of Marengo.
    8·1 answer
  • True or False? A website for a certain political party or candidate is likely to have unbiased information.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!