Hey ich habe mich an die Caesar-Verschlüsslung gesetzt und komm nicht weiter... :(
Das Problem ist das der keine Sätze verschlüsselt warum auch immer..
Da ich neu in C++ bin freu ich mich über Tipps aandd Tricks :D
Danke im vorraus :)
Das Problem ist das der keine Sätze verschlüsselt warum auch immer..
Da ich neu in C++ bin freu ich mich über Tipps aandd Tricks :D
Code:
#include <iostream>
#include <string>
using namespace std;
string crypt(string text,int chiffre) {
for(unsigned int i = 0; i < text.length(); i++) {
text[i] = text[i] + chiffre;
}
return text;
}
string decrypt(string text,int chiffre) {
for(unsigned int i = 0; i < text.length(); i--) {
text[i] = text[i] - chiffre;
}
return text;
}
int main()
{
string textc = "";
string textd = "";
char input = '0';
int chiffre = 0;
bool exit = false;
do{
cout << "Caesar-Chiffre" << endl << endl;
cout << "<1> Crypt" << endl;
cout << "<2> Decrypt" << endl;
cout << "<3> Exit" << endl;
cout << endl << "Input : ";
cin >> input;
switch(input) {
case '1' : cout << endl << "Text : ";
cin >> textc;
fflush(stdin);
cout << endl << "Chiffre : ";
cin >> chiffre;
fflush(stdin);
cout << endl << endl << crypt(textc,chiffre) << endl;
fflush(stdin);
getchar();
break;
case '2' : cout << endl << "Text : ";
cin >> textd;
cout << endl << "Chiffre : ";
cin >> chiffre;
cout << endl << endl << decrypt(textd,chiffre) << endl;
fflush(stdin);
getchar();
break;
case '3' : exit = true;
break;
default : cout << endl << "Fuck off choose a option from the list!" << endl << endl;
break;
}
}while(exit == false);
return 0;
}
Danke im vorraus :)