954,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

substitution cipher help

Been trying to make a substitution cipher decrypter, but it isn't working especially good. so I thought I might could get some help with it.

#include <iostream>
#include <time.h>
#include <windows.h>
#include <iomanip.h>
#include <string.h>

using namespace std;

int main()
{
    
    
    bool EndThisShit(false);
    do {
    string input;
    cin >> input;
    int il;
    input.length() = il;
    int Ninput[il];
    Ninput[il] = input
    int y;
    for( y = 0; y < il; y++){
    int t =1;
    Ninput[fo] + t;
    i++;
    t++;
}
 int a;
 for(a = 0; a < il; a++) {
       enum letter {  a = 97, b, c, d, e, f, g, h, i, j, k, l, m, n, o , p, q, r, s, t, u ,v, w ,x ,y ,z};
       int b = 0;
       cout Ninput[b] 
       b++; 
       }    
       cout << " is this a good solution? y/n >> ";
       char yn;
       cin >> yn; 
       if(yn == y) {
             EndThisShit = true;
             }
       if(yn == n) {
             EndThisShit = false;
             }
}while(!EndThisShit);
}
kangarooblood
Light Poster
42 posts since Jun 2009
Reputation Points: 6
Solved Threads: 2
 

What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.

daviddoria
Posting Virtuoso
1,996 posts since Feb 2008
Reputation Points: 437
Solved Threads: 204
 
What is it supposed to do. Maybe you can give sample input, current (incorrect) output, and expected output.


well it's supposed to give differet solutions to a Substitution cipher ( http://en.wikipedia.org/wiki/Substitution_cipher )
it should be writing a possible solutions and if it's the correct then finish it of, and if it's not it shall give another suggestion, until it finds the right one. right now nothing happends, all I get is an error message saying " `width' has not been declared" it's supposed to give every letter a specific array, then convert it to numbers, then add an increasing number to the letter number, then convert it back to the letter that is the increasing number after it. and then type it out.

#include <iostream>
#include <time.h>
#include <windows.h>
#include <iomanip.h>
#include <string.h>

using namespace std;

int main()
{
    
    
    bool EndThisShit(false);
    do {
    char input;
    cin >> input;
    int Ninput[1000];
    int li;
    li = input.width();
    Ninput[1000] = input;
    int Veckt[li];
    int fo=0;
    int letters[fo];
    
    int y;
    for(y = 0; y < li; y++){
    int t =1;
    Veckt[fo] = Ninput[fo] + t;
    Veckt[fo] = (char)letters[fo];
    fo++;
    t++;
}
 int a;
 for(a = 0; a < li; a++) {
       int bo = 0;
       cout << letters[fo]; 
       bo++; 
       }    
       cout << " is this a good solution? y/n >> ";
       char yn;
       cin >> yn; 
       if(yn == 'y') {
             EndThisShit = true;
             }
       if(yn == 'n') {
             EndThisShit = false;
             }
}while(!EndThisShit);
}


New code!

kangarooblood
Light Poster
42 posts since Jun 2009
Reputation Points: 6
Solved Threads: 2
 

What are all those headers for? Comments would also be nice so we can see what your doing.
Are you incrementing every character by one, and if the input is 'n', you increment every number again? What happens when you go past the printible character range?

Hiroshe
Posting Whiz in Training
256 posts since Jun 2008
Reputation Points: 431
Solved Threads: 17
 
What are all those headers for? Comments would also be nice so we can see what your doing. Are you incrementing every character by one, and if the input is 'n', you increment every number again? What happens when you go past the printible character range?

well I'm going to use the headers later, like adding some color and so on. And when I overcome the printable range (for the moment) nothing happends, then it's just not a substitution cipher and it's just to close the window down.

kangarooblood
Light Poster
42 posts since Jun 2009
Reputation Points: 6
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You