文件加密,最好有代码

Xhunter 2001-12-17 09:30:17
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxhywdh 2002-01-07
  • 打赏
  • 举报
回复
上面有点小错
看这个 !!!!

void jm(char *file,char *password)
{
int i,len,k;
unsigned long filelen;
char ch0[4097];
char tmpfile[255];
int fp0,fp1;
k=0;
len=strlen(password);
if(len<1) return ;
if((fp0=FileOpen(file,fmOpenRead))==-1)
{ ShowMessage("\n no this file: or file can not read !!!");
return ;
}

filelen = FileSeek(fp0,0,2);
FileSeek(fp0,0,0);
if(filelen>=4096) k=4096;
else if(filelen>=1024) k=1024; else k=1;
strcpy(tmpfile,"abcd1234.zzz");
fp1=FileCreate(tmpfile);
if(fp1==-1) {
fclose(fp0);
ShowMessage("\n can not creat or open file ");
perror(tmpfile);
return;}
i=0;
while(filelen>0) {
i=FileRead(fp0,&ch0,k);
if(i!=k) break;//READ ERROR
for(i=0;i<k;i++) ch0[i]^=password[i%len];
i=FileWrite(fp1,&ch0,k);
filelen-=k;
if(filelen>=4096) k=4096;
else if(filelen>=1024) k=1024;else k=1;}
FileClose(fp0);
FileClose(fp1);
DeleteFile(file);
RenameFile(tmpfile,file);
}


jxhywdh 2002-01-07
  • 打赏
  • 举报
回复
void jm(char *file,char password)
{
int i,len,k;
unsigned long filelen;
unsigned char c;
char ch0[4097],ch1;
char tmpfile[255];
int fp0,fp1;
k=0;
len=strlen(password);
if(len<1) return ;
if((fp0=FileOpen(file,fmOpenRead))==-1)
{ ShowMessage("\n no this file: or file can not read !!!");
return ;
}

filelen = FileSeek(fp0,0,2);
FileSeek(fp0,0,0);
if(filelen>=4096) k=4096;
else if(filelen>=1024) k=1024; else k=1;
strcpy(tmpfile,"abcd1234.zzz");
fp1=FileCreate(tmpfile);
if(fp1==-1) {
fclose(fp0);
ShowMessage("\n can not creat or open file ");
perror(tmpfile);
return;}
i=0;
while(filelen>0) {
i=FileRead(fp0,&ch0,k);
if(i!=k) break;//READ ERROR
for(i=0;i<k;i++) ch0[i]^=password[i%len];
i=FileWrite(fp1,&ch0,k);
filelen-=k;
if(filelen>=4096) k=4096;
else if(filelen>=1024) k=1024;else k=1;}

FileClose(fp0);
FileClose(fp1);
DeleteFile(file1);
RenameFile(tmpfile,file1);
}
SSHADOW 2002-01-07
  • 打赏
  • 举报
回复
请高手写出源码吧?
通一 2002-01-06
  • 打赏
  • 举报
回复
我也想要

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧