مرحبا
من خلال هذا الكود استطيع تشغيل البرنامج بهذه الطريقة ,
من خلال نافذة الاوامر CMD يتوجب علي كتابة الامر التالي ( e.exe -d c:\test.txt c:\test1.txt c:\key.txt ) (for decryption)
{
const string Useing = "Use it by this way [-e | -d] Dfile Sfile kfile ";
if(argc != 5)
{
cout << Using << endl;
return 1;
}
ifstream is(argv[3], ios::in | ios::binary);
if(!is)
{
cerr << "Input File Not Found Check it please" << endl;
return 2;
}
ifstream keyS(argv[4], ios::in | ios::binary);
if(!ks)
{
cerr << "Key File Not Found Check it please" << endl;
return 2;
}
AES aes;
const unsigned char *key = new unsigned char[16];
keyS.read((char*)key, 16);
ofstream os(argv[2], ios::out | ios::binary);
if(strcmp(argv[1], "-E") == 0 || strcmp(argv[1], "-e") == 0)
{
const unsigned char* cipherText;
const unsigned char* plainText = new unsigned char[16];
while(is.read((char*)plainText, 16))
{
cipherText = aes.Cipher(plainText, key, 16);
os.write((const char*)cipherText, 16);
}
}
if(strcmp(argv[1], "-D") == 0 || strcmp(argv[1], "-d") == 0)
{
const unsigned char* plainText;
const unsigned char* cipherText = new unsigned char[16];
while(is.read((char *)cipherText, 16))
{
plainText = aes.InvCipher(cipherText, key, 16);
os.write((const char*)plainText, 16);
}
delete[] cipherText;
}
delete[] key;
is.close();
keyS.close();
os.close();
return 0;
}
int main(int argc, char* argv[])
ولكنني أرغب بتشغيل البرنامج من خلال قائمة على الشكل التالي
من خلال نافذة الاوامر CMD كتابة اسم الملف E.exe
ومن ثم الحصول على قائمة بالشكل التالي
1- encrypt
2- decrypt
3- exit
بتمنى انكون تساعدوني بهالشي , انا حاولت بس ما زبطت معي.