马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 ~风介~ 于 2015-5-23 23:46 编辑
C Code:/* Usage: crypto key input_file output_file */
#include <stdio.h>
int main (int argc, char *argv[])
{
FILE *fi, *fo;
char *cp;
int c;
if ((cp = argv[1]) && *cp != '\0')
{
if ((fi = fopen(argv[2], "rb")) != NULL)
{
if ((fo = fopen(argv[3], "wb")) != NULL)
{
while ((c = getc(fi)) != EOF)
{
if (!*cp)
cp = argv[1];
c ^= *(cp++);
putc(c,fo);
}
fclose(fo);
}
fclose(fi);
}
}
return 0;
}
C++ Code:/* Usage: crypto key input_file output_file */
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc,char *argv[])
{
ifstream fin;
ofstream fout;
char ch;
char *cp;
fin.open(argv[2],ios_base::binary|ios_base::in);
fout.open(argv[3],ios_base::binary|ios_base::out);
if ((cp = argv[1]) && *cp != '\0')
{
while(!fin.eof())
{
if (!*cp)
cp = argv[1];
fin.get(ch);
ch ^= *(cp++);
fout.put(ch);
}
}
fin.close();
fout.close();
return 0;
}
Screenshot:
|