解释一下这段C语言代码的具体算法 解释的好的追加分啊!

来源:百度知道 编辑:UC知道 时间:2024/05/26 02:24:51
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

void encrypt(char *in, char *pwd, char *out)
{
FILE *infile, *outfile;
char ch;
int i=0, PwdLen=0;
if ((infile=fopen(in, "rb"))==NULL)
{
printf("无法打开 %s\n", in);
getch();
exit(1);
}
if ((outfile=fopen(out, "wb"))==NULL)
{
printf("无法打开或创建 %s\n", out);
getch();
exit(1);
}
while (pwd[PwdLen++]); //这里用来应付密码为空的情况
PwdLen--;
ch=fgetc(infile);
while (!feof(infile))
{
fputc(ch^pwd[i>=PwdLen?i=0:i++], outfile);
ch=fgetc(infile);
}
fclose(infile);
fclose(outfile);
}

int main(int argc, char *argv[])
{
char in[256];
char out[256];
char pwd[256];
if (argc!=4)
{
printf("要加/解密的文件:\n");
gets

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>

void encrypt(char *in, char *pwd, char *out)
//简单说这个函数是将文件in复制到文件out,中间使用pwd密码编码
{
FILE *infile, *outfile;
char ch;
int i=0, PwdLen=0;
if ((infile=fopen(in, "rb"))==NULL) //判断文件存在创建
{
printf("无法打开 %s\n", in);
getch();
exit(1);
}
if ((outfile=fopen(out, "wb"))==NULL) //判断文件存在创建
{
printf("无法打开或创建 %s\n", out);
getch();
exit(1);
}
while (pwd[PwdLen++]); //这里用来应付密码为空的情况
PwdLen--;
ch=fgetc(infile);
while (!feof(infile))
{
fputc(ch^pwd[i>=PwdLen?i=0:i++], outfile); //读文件in内容编码后写到out
ch=fgetc(infile);
}
fclose(infile);
fclose(outfile);
}

int main(int argc, char *argv[])
{
char in[256];
char out[256];
char pwd[256];