No matter in the Web page or the software on the login time will encounter the problem of verification code, do not know the secret of the Code of the Friends have no interest together to explore.
In fact, there is no mystery, that is, to generate random numbers, and then let the resulting random number as the word repertoires (pre-made digital letter string) subscript, so from the word repertoires randomly extracted from the composition of the small string is the simplest string, of course, you can create your own word repertoires content.
Here is the code for the process of writing the verification Code and verifying the verification code in C language:
#include <stdio.h>#include<stdlib.h>#include<time.h>#include<string.h>#defineN 5voidIdentifying_code (CharStr[],intN) {intI,j,len; CharPstr[] ="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJLMNOPQRSTUVWXYZ"; Len= strlen (PSTR);//to find the length of a string pstrSrand (Time (0)); for(i =0; i < n; i++) {J= rand ()%len;//generate a random number of 0~len-1Str[i] =Pstr[j]; } Str[i]=' /';}intMain () {intn =3; intFlag =0; Charcode[n+1],str[n+1]; while(n) {identifying_code (code,n); printf ("Please enter the verification code < You have%d chance >:%s\n", N,code); scanf ("%s", str); N--; if(strcmp (code,str) = =0) {//case-sensitive verification coden =0; Flag=1; printf ("verify correct. \ n"); } } if(Flag = =0) printf ("Sorry, your account is locked. \ n"); return 0; }
Welcome code Friends Comments, I will continue to modify to make it perfect, thank you for your support.
Generation and verification of the >c language---verification codes generated by < verification codes