Question
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 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...