QuestionQuestion

You are responsible to an assembly function for an encryption library. This function will encrypt or decrypt a string of characters. It will use a simple ciphertext algorithm which do character shifting. This function will use the C function signature but everything within this function should be assembly code using the ASM block similar to the assembly example shown in class. This function should be built into a separate DLL with the p4.cpp will contain the calling functions.

Program Specification:

int s_encrypt (char *src, char* dest, int en_flag);

src – the original string

dest – the output string

en_flag – 0 for encryption and 1 for decryption

This function returns the # of characters being changed in the string. If no change, it should return zero.

Additional Information:

- We only apply the change algorithm for (‘A’..‘Z’ to ‘a’..’z’). Other characters are left unchanged.
- We will use a separate header file (key.h) for the character shifting algorithm.
- The input and output string are displayed on the screen.
- You MUST have detailed comments within the _asm block for your algorithm.
- In key.h, you have 3 global variables named
int direction = 0; /* 0 means forward, 1 means backward */
       int shiftcount = 2; /* number of character to shift */
int invertcase = 1; /* invert case of the original letter, 0 = no, 1 = yes */

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

/*
encrypt.cpp - This file contains the code to encrypt and decrypt an input string
                and output the modified string.
*/

#include "key.h" /* Okay to use the 3 symbolic names inside key.h */
#include <string.h>

__declspec(dllexport) int s_encrypt (char *src, char* dest, int en_flag);


__declspec(dllexport) int s_encrypt (char *src, char* dest, int en_flag)
{
int i;
int cnt;
int cas;
int startaddress;

__asm
{
mov eax, 0 ; zero out the result
mov esi, src ; move the source string pointer to ESI
; fill in your code here
mov edi, dest
mov i, 0
mov cnt, 0
mov startaddress, 0x41
mov cas, 0x20...
$35.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats