編寫(xiě)自解密程序
ch=chpassword[i];本文引用地址:http://2s4d.com/article/148822.htm
ch+=I;
ch=nch; /*將此字符同密碼i值進(jìn)行運(yùn)算后寫(xiě)入fp2指定文件*/
fputc(ch,fp2);
}
}While(!feof(fp1));
fcloseal?;
}
第二個(gè)源代碼文件main2.c
#include “stdio.h
#include “string.h
main(int argc,char *argv[])
{FILE *FP0,*FP1;
char *password,old password[10],str[10],ch,I;
if(argc!=2)
{printf(“Usage=%s,argv[0]);
exit(o);
}
fseek(fp0,16888L,SEEK_SET); /*同理16888也視實(shí)際情況而定*/
fgetc(fp0); /*讀掉一個(gè)無(wú)效字符*/
for(i=0;(oldpassword[i]=fget((fp0))!=`10`;i++)
Oldpassword[i]=(oldpassword[i]i)-I; /*對(duì)密碼進(jìn)行還原*/
oldpassword[i]=`10`; /*把“10”藏于密碼后 */
password=(char *)getpass(“please input password:);
for(i=0;I {if(strcmp(password,oldpassword))
{password=(ch *)getpass(“
password is wrong.
please input agai:);
if(i==2)
{printf(“
press any Key to exit……
);
getch();exit(o)
}
}
}/*對(duì)密碼進(jìn)行判斷,有三次機(jī)會(huì),都不正確則返回到操作系統(tǒng)*/
do{
for (i=0;password[i]!=`10`;i++)
{ch=fgetc(fp0);
if(feof(fp0))break;
ch=nch;
ch-=I;
ch=password[i];
}
}while(!feof(fp0);
fcloseal?;
{
上述程序在COMPAQ 586.TC2.0集成環(huán)境里通過(guò)。
評(píng)論