I need a little bit of help to finish this program cant get

I need a little bit of help to finish this program, can\'t get it to work. Please and thank you.

Write a program that encrypts a string of text with a maximum size of 80 characters by XOR’ing a hex AC to each character in the input buffer. The program will display the input buffer, the encrypt buffer and the decrypted buffer. Your program will display each char of the buffer as a hex character. You will use an InputBuffer of size 81, a EncryptedBuffer of size 81, and a ClearBuffer of size 81.

No global variables can be used.

You can use an inline assembly program in this case (Mixed Mode Solution)

In C++ you can declare the 3 buffers and perform the getline and the character count resulting from the getline function. Suggest using char InputBuffer[81]; for example in C++ with the corresponding cin.getline instruction. The actual encrypting and decrypting must be done in assembly. Then the display can be done in C++ again.

***********************

#include <iostream>

using namespace std;

int main() {

   char InputBuffer[81];

   char EncryptedBuffer[81];

   char ClearBuffer[81];

   int count = 0;

   cout << \"Enter a string of text\" << endl;

   cin.getline(InputBuffer, sizeof(InputBuffer));

   count = cin.gcount();

   __asm {

       mov esi, 0

       mov edi, 0

       L1:

           mov al, InputBuffer[esi]

           xor al, 0ach

           mov EncryptedBuffer[edi], al

           inc esi

           inc edi

           loop L1

   }

   cout << \"Encrypted buffer: \" << EncryptedBuffer << endl;

   __asm {

       mov esi, 0

       mov edi, 0

       L2:

           mov al, EncryptedBuffer[esi]

           xor al, 0ach

           mov ClearBuffer[edi], al

           inc esi

           inc edi

           loop L2

   }

   cout << \"Decrypted buffer: \" << ClearBuffer << endl;

   return 0;

}

Solution

Solution:

#include <iostream>
using namespace std;
int main() {
    char InputBuffer[81];
    char EncryptedBuffer[81];
    char ClearBuffer[81];
    int count = 0;
    cout << \"Enter a string of text\" << endl;
    cin.getline(InputBuffer, sizeof(InputBuffer));
    count = cin.gcount();
    __asm {
        mov esi, 0
        mov edi, 0
        L1:
            mov al, InputBuffer[esi]
           mov al, 0ach
            xor EncryptedBuffer[edi], al
            inc esi
            inc edi
            loop L1
    }

    cout << \"Encrypted buffer: \" << EncryptedBuffer << endl;
   __asm {
        mov esi, 0
        mov edi, 0
        L2:
            mov al, EncryptedBuffer[esi]
           mov al, 0ach
            xor ClearBuffer[edi], al
            inc esi
            inc edi
            loop L2
    }
    cout << \"Decrypted buffer: \" << ClearBuffer << endl;
    return 0;
}

I need a little bit of help to finish this program, can\'t get it to work. Please and thank you. Write a program that encrypts a string of text with a maximum s
I need a little bit of help to finish this program, can\'t get it to work. Please and thank you. Write a program that encrypts a string of text with a maximum s
I need a little bit of help to finish this program, can\'t get it to work. Please and thank you. Write a program that encrypts a string of text with a maximum s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site