step through the string and use the char encoder to encode each char in the string. |
|
|
|
|
but you can break these easily if you see what it is from the data, just put in "aaaaaaaaaaaaaaaaaaaaaaaaaa" and it will tell you the cipher (lookup) used. |
Your charEncoder function seems like it needs more information, it needs to know how it's being encoded. |
A plaintext char is received as input and shifted according to the current place in the codeword |
|
|
So if you have ascii code 125 and you add 3 to it, it'll go from '}' to '!'. |
|
|
enc_string.length()
will be 0, due to what I said in Line 2. enc_string[i];
charEncoder(char)
Given only a char, how do you know what place that char is in the string (or, how do you know what the shift amount is during the encode)? Think about that. |
What are you trying to do here? This line, by itself, doesn't do anything. |
Line 2: This initializes an empty string. You probably want to initialize the string so that it has the same length as the input string (enc), otherwise you'd be going out of bounds. |
I very much have been. My guess would be to store the string in an array and then on each run of charEncoder in the encode function pass the char to the charEnocder function. |
A plaintext char is received as input and shifted according to the current place in the codeword. The shifted char is returned. |
char charEncoder(char ch, int place)
? Otherwise, the requirements don't make sense.Would I set it = to something |
From that, are you allowed to change the signature of the charEncoder function? i.e. make it char charEncoder(char ch, int place)? Otherwise, the requirements don't make sense. However, since you're using a class, you could skirt around this by having a class member variable that keeps track of the current place in the string, but I don't condone this. |
i.e. make it char charEncoder(char ch, int place)? |
Yes, since your charEncoder function returns a char, set it to the return value of the charEncoder function. |
|
|