Help

Can anyone help me write a decryption program that looks like this? I'm so lost since my teacher sucks and the book is very brief on the details


************************************************
Welcome to
The DECRYPTER


You have the option of performing either
a Caesar decryption
or
a Substitution decryption.

You will be asked for a file to be decoded.

The DECRYPTER will then echoprint one line
of your encoded text from your specified file
followed by the same text decoded.
************************************************

What would you like to do?
To decode a text file using the substitution cypher, press s
To decode a text file using the Caesar cypher, press c
To quit decoding, press q
What is your selection ? a
Sorry, that was not a valid input. Please try again.

What would you like to do?
To decode a text file using the substitution cypher, press s
To decode a text file using the Caesar cypher, press c
To quit decoding, press q
What is your selection ? 1
Sorry, that was not a valid input. Please try again.

What would you like to do?
To decode a text file using the substitution cypher, press s
To decode a text file using the Caesar cypher, press c
To quit decoding, press q
What is your selection ? c

File names must not contain blanks.
Please enter the file name to decode -> caesarSML.txt
************************************************
The DECRYPTER
of
Substitution Scheme Encryption
Using Caesar Substition set
************************************************


Original alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift Value: 6
Encrypted alphabet: GHIJKLMNOPQRSTUVWXYZABCDEF


ZNOY OY G YOSVRK ZKYZ ZU YKK
=> THIS IS A SIMPLE TEST TO SEE


OL ZNK VXUMXGS CUXQY. OL EUA
=> IF THE PROGRAM WORKS. IF YOU


IGT XKGJ ZNOY, ZNKT KBKXEZNOTM
=> CAN READ THIS, THEN EVERYTHING


OY UQ.
=> IS OK.




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

What would you like to do?
To decode a text file using the substitution cypher, press s
To decode a text file using the Caesar cypher, press c
To quit decoding, press q
What is your selection ? s

File names must not contain blanks.
Please enter the file name to decode -> encodedstuff.jnk
Sorry, "encodedstuff.jnk" is not a valid file name. Please try again.

Please enter the name of the file to decode -> fred
Sorry, "fred" is not a valid file name. Please try again.

Please enter the name of the file to decode -> subSML.txt
************************************************
The DECRYPTER
of
Substitution Scheme Encryption
Using Substitution set
************************************************


Original alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Encrypted alphabet: MLKJIHGFEDCBAZYXWVUTSRQPON


TFEU EU M UEAXBI TIUT TY UII
=> THIS IS A SIMPLE TEST TO SEE


EH TFI XVYGVMA QYVCU. EH OYS
=> IF THE PROGRAM WORKS. IF YOU


KMZ VIMJ TFEU, TFIZ IRIVOTFEZG
=> CAN READ THIS, THEN EVERYTHING


EU YC.
=> IS OK.




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

What would you like to do?
To decode a text file using the substitution cypher, press s
To decode a text file using the Caesar cypher, press c
To quit decoding, press q
What is your selection ? q

************************************************
Thank you for using
The DECRYPTER
************************************************
Press any key to continue . . .




There are 2 files i need to use "caesar.txt" and "sub.txt" Thank you
what have you got so far?

asking specific questions will probably be more beneficial for you.
I don't have much, i know all the cout stuff and the basics, but i just need to know how to even use the decryptions, where to put them, and how to open the files and where to organize everything
kan u go straight 2 de questions..
#include <iostream>
#include <fstream>
using namespace std;

int main(void)
{
cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << endl;
cout << “WELCOME TO THE DECRYPTER!” << endl;
cout << “Here you can choose to either perform<< endl;
cout << “a CAESAR decryption or” << endl;
cout << “a SUBSTITUTION decryption.”<< endl;
cout << “You will be asked for a file to be decoded.”<< endl;
cout << “The DECRYPTER will then echo print one line”<< endl;
cout << “of your encoded text from your specified file“<< endl;
cout << “foliowed by the same text decoded.”<< endl;
cout << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"<< endl;
{

char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
char cipher[] = "qwertyuiopasdfghjklzxcvbnm";
char message[] = "io knqf";

int message_length = sizeof(message)/sizeof(message[0]);


for(int i = 0; i < message_length - 1; i++)
{


if(message[i] != ' ')
{

for(int c = 0; c < 26; c++)
{

if(cipher[c] == message[i])
{
message[i] = alphabet[c];
c = 26;
}
}
}
cout << message[i];
}

cout << endl;
}
return 0;
}

First things first, get the decryption working. Write some code into this driver program so that when you run it, you get the alphabet to print out in order:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>

char decryptSub(char e)
{
    //write code here that returns the decrypted version of
    //the character parameter 'e' (substitution version)
}

char decryptCes(char e)
{
    //write code here that returns the decrypted version of
    //the character parameter 'e' (Caesar version)
}

int main()
{
    std::string subAlphaEncrypted("MLKJIHGFEDCBAZYXWVUTSRQPON");
    for(unsigned j = 0; j < subAlphaEncrypted.size(); j++)
    {
        std::cout << decryptSub(subAlphaEncrypted[i]);
    }
    std::cout << std::endl;

    std::string cesAlphaEncrypted("GHIJKLMNOPQRSTUVWXYZABCDEF");
    for(unsigned j = 0; j < cesAlphaEncrypted.size(); j++)
    {
        std::cout << decryptCes(cesAlphaEncrypted[i]);
    }
    std::cout << std::endl;
    return 0;
}

Your output should look like:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ

This will prove to you that your decryption works for each character by taking the encrypted alphabets (subAlphaEncrypted and cesAlphaEncrypted) and turning them back into the regular alphabet using the appropriate decryption.
Topic archived. No new replies allowed.