计算机网络安全研究协会第二期部分程序代码
c语言吧
全部回复
仅看楼主
level 2
zfy0422 楼主
计算机网络安全研究协会第二期部分程序代码 ———一个密码验证程序的编写组稿人:赵飞宇 本程序由刘杨编写#include
#include
#include
#include
main(){FILE *fp;struct d_type{ char name[13]; char password[13];}d[2];long size;int ch=-1,b=2,i=0,j=0,e=0,f,p;int gr=DETECT,gm;initgraph(&gr,&gm,"");/* d[0].name,d[1].name分别存储键盘和文件输入的昵称记录 * d[0].password,d[1].password分别存储键盘和文件输入的密码记录 * ch接受键盘按键 * b判断当前焦点位置:4=登陆(回车),1=注册,2=昵称,3=密码 * i,j分别记录已输入昵称和密码的个数 * e记录提示信息 * f,p分别用于读取文件和加密数据的循环控制 * gr那两行用来进入图形模式 */cleardevice();setbkcolor(9);setfillstyle(9,1);bar(240,160,440,280);setfillstyle(1,7);bar(220,140,420,260);setfillstyle(1,1);bar(220,140,420,160);setcolor(8);rectangle(221,161,421,261);setcolor(15);rectangle(220,140,420,260);line(221,259,419,259);line(419,162,419,259);rectangle(240,230,310,247);rectangle(330,230,400,247);setcolor(8);line(241,248,310,248);line(311,231,311,248);line(331,248,401,248);line(401,231,401,248);setfillstyle(1,9);bar(304,180,407,215);rectangle(303,179,408,216);line(303,197,408,197);setcolor(15);rectangle(303,179,408,197);outtextxy(225,145,"Land:");setcolor(8);outtextxy(230,185," Name:");outtextxy(230,205,"Password:");outtextxy(245,235," Login ");outtextxy(335,235,"Register");setcolor(14);rectangle(303,179,408,197);/* 以上用于绘制图形界面 */do{ ch=-1; while(ch==-1){ ch=bioskey(0); }/* 等待用户按键并赋给变量ch */ switch(ch){ case 3592:/*退格键*/ if(b==2&&i>0){gotoxy(38+i,11); putchar(' ');i=i-1; } if(b==3&&j>0){gotoxy(38+j,12);putchar(' ');j=j-1; } break;/* 删除一个当前焦点b所在的字符 */ case 3849:/* Tab键 */ switch(b){ case 1:/*注册*/ setcolor(15); rectangle(330,230,400,247); setcolor(14); rectangle(303,179,408,197); b=2; break; case 2:/* 昵称 */ setcolor(8); rectangle(303,179,408,197); setcolor(14); rectangle(303,197,408,216); b=3; break; case 3:/* 密码 */ setcolor(8); rectangle(303,197,408,216); setcolor(14); rectangle(240,230,310,247); b=4; break; case 4:/* 登陆 */ setcolor(15); rectangle(240,230,310,247); setcolor(14); rectangle(330,230,400,247); b=1; break; } break;/* 向下切换当前焦点位置 */ case 7181:/* 回车键 */ switch(b){ case 2: setcolor(8); rectangle(303,197,408,179); setcolor(14); rectangle(240,230,310,247); b=4;case 3: if(b==3){ setcolor(8); rectangle(303,197,408,216); setcolor(14); rectangle(240,230,310,247); b=4;
2004年11月09日 04点11分 1
level 2
zfy0422 楼主
}/* 还原用户昵称输入框状态,将焦点跳至登陆按钮 */case 4: d[0].name[i]='\0'; d[0].password[j]='\0';/* 将键盘输入的昵称,密码加上结束符 */ gotoxy(30,17); if((fp=fopen("db.dat","rb"))==NULL){ if((fp=fopen("db.dat","wb"))==NULL){ printf("Cannot open file\n"); exit(0); } } /* 读取磁盘文件“DB.DAT”,如不存在则新建 */ fseek(fp,0L,2); size=ftell(fp); if(size%26!=0){ fclose(fp); if((fp=fopen("db.dat","wb"))==NULL){ printf("Cannot open file\n"); exit(0); } printf("数据库文件已损坏,已经重建"); break; } fseek(fp,0L,0); /* 测试数据文件长度,判断是否符合结构体定义的数据块长度,并将文件指针指向文件头 */ for(f=0;f<(size/26);f++){ fread(&d[1],sizeof(struct d_type),1,fp); for(p=0;p
2004年11月09日 04点11分 2
level 2
zfy0422 楼主
版主啊,看来小弟是不适合在这上面发这些东西的,以后我就不发了,免得招人讨厌,在此道歉。小弟手中真的有许多好的程序,其中加密解密,密码验证,还有用c语言编写的画图工具都是不错的,如果谁感兴趣的话,可以发邮件给我,我发给你。[email protected]
2004年11月10日 00点11分 3
level 2
zfy0422 楼主
是的,我们协会从第一期开始,我就说面向客户,树立一种商业化的思想,后来我们用开发工具做一些大点的程序的时候,我发现许多人都养成了很好的习惯,习惯于写代码的同时也习惯于写帮助文档,注意界面也是有好处的,不过却是如你所言,对c语言的学习没有什么好处。
2004年11月11日 03点11分 6
1