How to realize Color CAPTCHA Code by JSP
This article is about how JSP implements color CAPTCHA. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Generate a picture with 4 random numbers and a cluttered background, the number and background color will change, and the server will refresh (also change with history.go (- 1)).
The file http://blog.itpub.net/9650775/viewspace-922495/image.jsp that produces the CAPTCHA image
255) fc=255
If (bc > 255) bc=255
Int r=fc+random.nextInt (bc-fc)
Int g=fc+random.nextInt (bc-fc)
Int b=fc+random.nextInt (bc-fc)
Return new Color (rmae gpene b)
}
% >