بسم الله الرحمن الرحيم
يا اخوان انا لدي هذا البرنامج
قمت بهذه المحاوله و لا توجد errors
و لكن المشكله هي بعد ادخال النص المراد تشفيره او فك تشفيره لا يحد اي شئ
فقط ادخل النص ثم يقول press any key to continue ...
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main() {
string strTarget;
int choice;
cout<<"Enter your choice";
cin>>choice;
if (choice = 1) {
cout << "Enter a string to encrypt: ";
cin >> strTarget;
getline(cin,strTarget);
string temp(strTarget);
int len = strTarget.length();
char a;
string strFinal(strTarget);
for (int i = 0; i <= (len-1); i++)
{
a = strTarget.at(i);
int b = (int)a; //get the ASCII value of 'a'
b += 5; //Mulitply the ASCII value by 5
a = (char)b; //Set the new ASCII value back into the char
strFinal.insert(i , 1, a); //Insert the new Character back into the string
cout << "Encrypted: " << strTarget << endl;
}
string strEncrypted(strFinal, 0, len);
strTarget = strEncrypted;
}
else if (choice = 2) {
cout << "Enter a string to decrypt: ";
cin >> strTarget;
getline(cin,strTarget);
string temp(strTarget);
int len = strTarget.length();
char a;
string strFinal(strTarget);
for (int i = 0; i <= (len-1); i++)
{
a = strTarget.at(i);
int b = (int)a; //get the ASCII value of 'a'
b -= 5; //Mulitply the ASCII value by 5
a = (char)b; //Set the new ASCII value back into the char
strFinal.insert(i , 1, a); //Insert the new Character back into the string
cout << "Decrypted: " << (strTarget) << endl;
}
string strEncrypted(strFinal, 0, len);
strTarget = strEncrypted;
}
}