一个非常简单的加解密程序)
作者:互联网
#include <cstdio>
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;
const int maxn = 1e5 + 10;
char str[maxn];
int main()
{
string filename;
cout << "input file's name:\n";
cin >> filename;
ifstream fin(filename, ios::binary);
if (!fin)
{
cout << "Error\n";
return 0;
}
cout << "output file's name\n";
cin >> filename;
ofstream fout(filename, ios::binary);
if (!fout)
{
cout << "Error\n";
return 0;
}
cout << "encode/decode key:\n";
int key;
cin >> key;
while (fin)
{
fin.read(str, maxn - 10);
int n = fin.gcount();
for (int i = 0; i < n; ++i)
{
str[i] = (~str[i]) ^ key;
}
fout.write(str, n);
}
cout << "succeed\n";
}
标签:非常简单,cout,int,加解密,程序,filename,str,include,fin 来源: https://www.cnblogs.com/eafoo/p/16270993.html