There are many image verification code forms on the Internet. Those verification codes that do not generate images have anti-cracking defense capabilities that are simply vulnerable; some people directly display specific numbers in the web source code, and then ask the visitor to enter an added sum; such as 3+5=, there are some new features of such verification codes, but unfortunately, they have no protection at all.
flymorn improves the above novelty, directly use the asp program to generate the Bmp image format, and store the sum of the numbers into the session to increase the threshold for cracking; people without some knowledge of graphics and iconography cannot crack it. The code is as follows:
The code copy is as follows:
<%
Response.Buffer=True
Response.ExpiresAbsolute=Now()-1
Response.Expires=0
Response.cachecontrol="no-cache"
Response.ContentType="Image/Bmp"
CallCom_CreatValidCode()
SubCom_CreatValidCode()
Randomize
Dimi,ii,iii
ConstcAmount=10' Number of values
ConstcCode="0123456789"'Numerical range
DimvColorData(2)
vColorData(0)=""'The black dot should be converted into a color dot, not defined for the time being
vColorData(1)=ChrB(255)&ChrB(255)&ChrB(255)'White dot
DimvCode(4),vCodes' generates a set of arbitrary numbers
Fori=0To3
vCode(i)=Int(Rnd*cAmount)'Array equals total number*random number
ifi=1thenvCode(i)="11"'The second digit is +
ifi=3thenvCode(i)="10"'The fourth digit is =
vCodes=vCodes&Mid(cCode,vCode(i)+1,1)' String is equal to the string plus the subsequent value
Next
session("checkcode")=int(Mid(vCodes,1,1))+int(Mid(vCodes,2,1))' Calculate the sum and assign the value to the session
DimvNumberData(36)
vNumberData(0)=
"1110000111110111101111011110111101111011110111101111011110111101111011110111101111011111011110111110111110111110111110001111111110111110000111"
vNumberData(1)=
"11110111111110001111111111111111011111111111111011111111111111111111111111111111111111111111111111111111111111111111111111100000111"
vNumberData(2)=
"1110000111111011111011111111011111111101111111111101111111111111111111111111111111111111111111111111111111111111111101111111011111100000011"
vNumberData(3)=
"11100001111110111110111111101111111101111111011111110011111111111111111111111111111111111011111110111111011111101111110001111"
vNumberData(4)=
"1111110111111111110111111101111110111111011111101111110111111011111101111110000011111111111111110111111111000011"
vNumberData(5)=
"110000000111111111111111101111111011111011111011111101111111101111111111011111110111111011111101111110111111011111101111110001111"