Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having problems on where to begin. I have to decrypt an encoded message. Th

ID: 3628761 • Letter: I

Question

I'm having problems on where to begin. I have to decrypt an encoded message. The message is :mmZdxZmx]Zpgy. It is based on ASCII code. The encryption is as follows:

if(OriginalChar + Key > 126) then
EncryptedChar = 32 + ((OriginalChar + Key) - 127

Else
EncryptedChar = (OriginalChar + key)

the key is a number between 1-100. When you use the right number, the message will make sense.

I know I need a decrypt function. I set it up like this. This is in c++ by the way. Basically the message loops through a decrypt function until the key(which is can be 1-100) makes the message make sense.

#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <cctype>

using namespace std;

void decrpyt(char encoded[], char decoded[], int key)
{
    char encoded[] = ":mmZdxZmx]Zpgy";
    int i;
    char e, d;
        for(i = 0; i < strlen(encoded); i++)
        {
            e = encoded[i];
            if((e-key) < 32)
            {
                d = e + 127-32-key;
            }
        }
}


int _tmain(int argc, _TCHAR* argv[])
{
    return 0;
}

Explanation / Answer

please rate - thanks

#include<iostream>
using namespace std;
int main()
{char encode[]={":mmZdxZmx]Zpgy"};
char decode[100];
int key = 1,count;
char choice;
for(key = 1; key <= 100; key++)
{for(count = 0; count < strlen(encode); count++)
{if(encode[count] +key >126)
    decode[count] = 32+((encode[count] + key) -127);
   else
    decode[count] = encode[count] + key;
}
cout<<"Key = "<<key<<endl;
cout<<decode<<endl;
cout<<"Does the decode make sense(y/n)?"<<endl;
cin>>choice;
choice = tolower(choice);
if(choice == 'y'||choice=='Y')
   exit(1);
}
system("pause");
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote