- #1
davidhedoesit
- 2
- 0
Your program will ask the user for a text string to encrypt and a key (key). You will loop through the
string setting left to the first character and right to the second, and encrypt this with 3 Feistel rounds, and
output the text as hexidecimal. Continue to loop through the string using the 3rd and 4th characters and left
and right, etc. If the input string has an odd number of characters, pad the end with a space.
my problem is that i cannot figure out how to write the for loop that breaks up the string into left and right. any suggestions would be appreciated. at the bottom is the diagram i was given.
my code for the outer for loop is
i am trying to break the entered string like "The cat" up into left = T and right = h for the first loop and left = e and right = (white space)for the second loop...ect if the entered string is odd i would pad it with a space
View attachment 4950
string setting left to the first character and right to the second, and encrypt this with 3 Feistel rounds, and
output the text as hexidecimal. Continue to loop through the string using the 3rd and 4th characters and left
and right, etc. If the input string has an odd number of characters, pad the end with a space.
my problem is that i cannot figure out how to write the for loop that breaks up the string into left and right. any suggestions would be appreciated. at the bottom is the diagram i was given.
my code for the outer for loop is
i am trying to break the entered string like "The cat" up into left = T and right = h for the first loop and left = e and right = (white space)for the second loop...ect if the entered string is odd i would pad it with a space
Code:
#include <vector>
#include <cstdlib>
#include <iostream>
using namespace std;int main(){
int left;
int right;
int temp;
string userString;
int key=0;
cout << "Enter a sting to encript: ";
getline(cin,userString);
for (int i = 0; i <= userString.length(); i++){
left = userString.at(0);
right= userString.at(1);
cout<<left<<endl;
cout<<right;
}//through character loop
return 0;
}
View attachment 4950
Attachments
Last edited: