每次做完一个东西,总有一点东西能总结出来。
这次是做一个检验码,其中是使用des算法,做的时候还上网找资料,花了一段时间。把东西放在附件中了。
同时自己写了一个检证是否是 ip地址的检验:
int LH_chargetoip(unsigned int server_ip_address[4],const char *ip ) { const char *s="."; char TempIP[20]={0}; char *IP1; char *IP2; char *IP3; char *IP4; strcpy(TempIP,ip); IP1=strtok(TempIP,s); IP2=strtok(NULL,s); IP3=strtok(NULL,s); IP4=strtok(NULL,s); if (IP1!=NULL&&IP2!=NULL&&IP3!=NULL&&IP4!=NULL ) { //server_ip_address server_ip_address[0] = (unsigned int)atoi(IP1); server_ip_address[1] = (unsigned int)atoi(IP2); server_ip_address[2] = (unsigned int)atoi(IP3); server_ip_address[3] = (unsigned int)atoi(IP4); return 1; } return 0; } // int LH_checkstrIsIP(unsigned int server_ip_address[4],const char *ip ) { int nResul = 0; nResul = LH_chargetoip(server_ip_address,ip); if (nResul==1) { int i = 0; for(i = 0;i<4;i++) { if (0>server_ip_address[i]|| server_ip_address[i]>255) { return -2; } } } return 1; }