⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiami.c

📁 能够对文本文件进行加密
💻 C
字号:
# include "stdio.h"
# include "stdlib.h"
FILE *fp;
unsigned char xx[500][80],yy[20];
int total=0;
main(int argc,char *argv[])
{
    int i=0,j=0,k=0,l=0;
      if(argc<2){
	printf("\n parameter is null\n usage: jiami c:\\a.txt\n");
	exit(1);
    }
puts("please input correct password:\n");
while(l<3){
for(k=0;(yy[k]=getch())!='\r';k++)
	printf("$");
yy[k]='\0';
if(strcmp(yy,"jiangliyang")!=0)
	{printf("\npassword is wrong\nplease repeat!\n");l++;}
else break;}
if(l>=3){
	puts("sorry,you can't continue!");
	exit(1);
}
    if((fp=fopen(argv[1],"r"))==NULL){
	printf("can't open file!\n");
	exit(1);
    }
    printf("\nreading file.....\n");
   while(!feof(fp)){       /*read in*/
	 fgets(xx[i],80,fp);
	 i++;
    }
   fclose(fp);
   puts("reading file over!");
   printf("the total lines is: %d\n",i);
   total=i;
   if((fp=fopen(argv[1],"w"))==NULL){
	printf("can't open file!\n");
	exit(1);
    }
   if(strcmp(xx[0],"this document has protected by site120\n")==0)
	{
		strcpy(xx[0],"this document has protected by site120 \n");
		for(i=0;i<total;i++)
			fputs(xx[i],fp);
		fclose(fp);
		puts("the first jiemi successful!");
		}
  else if(strcmp(xx[0],"this document has protected by site120 \n")==0)
	{
		for(i=1;i<total;i++)
			for(j=0;j<strlen(xx[i]);j++)
				{xx[i][j]=xx[i][j]-1;}
		for(i=1;i<total;i++)
			fputs(xx[i],fp);
		fclose(fp);
		puts("the second jiemi successful!");
		}
  else{
	 for(i=0;i<total;i++)		/*jiami-------------->>-start */
	for(j=0;j<strlen(xx[i]);j++)
		{
			xx[i][j]=xx[i][j]+1;
		}

   fputs("this document has protected by site120\n",fp); /*output*/
   for(i=0;i<total;i++)
	fputs(xx[i],fp);
  fclose(fp);
	puts("the first jiami successful!");	}	/*jiami--------------->>-end */


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -