#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char inputFile[260];
char outputFile[260];
char password[100];
cout << "=== XOR Шифратор ===" << endl;
cout << "Введите имя входного файла: ";
cin >> inputFile;
cout << "Введите имя выходного файла: ";
cin >> outputFile;
cout << "Введите пароль: ";
cin >> password;
ifstream f_in(inputFile, ios::binary);
ofstream f_out(outputFile, ios::binary);
if (!f_in)
{
cout << "Ошибка открытия входного файла!" << endl;
system("pause");
return 1;
}
if (!f_out)
{
cout << "Ошибка создания выходного файла!" << endl;
system("pause");
return 1;
}
unsigned char b;
int k = 0;
while (f_in.read((char*)&b, sizeof(b)))
{
b = b ^ password[k++];
if (password[k] == '\0')
k = 0;
f_out.write((char*)&b, sizeof(b));
}
f_in.close();
f_out.close();
cout << "Готово!" << endl;
system("pause");
return 0;
}