getuserkeyfromargv(userkey,szKey); //生成密钥
//打开加/解密文件流
if ((fp=fopen(filename,"r+b"))==NULL)
{
printf("\nError opening File %s\n",filename);
exit (-1);
}
//打开辅助文件流
if ((temp=fopen(tempfilename,"w+b"))==NULL)
{
printf("\nError opening temporary file\n");
exit(-1);
}
// 直接对文件加/解密
if (to_or_from==1)
{
printf("\nEncoding file %s ",filename);
cipher_file(fp,temp,userkey);
}
else // 生成独立的加/解密文件
{
printf("\nDecoding file %s ",filename);
decipher_file(fp,temp,userkey);
}
//用完文件,关闭文件流
fclose (fp);
fclose(temp);
swap_files_and_clean_up(filename);
system("PAUSE");
}while(1);
}
|