Tasks: About the application time of the verification code: 0.5 days detailed design Each time you enter the registered interface, you need to increase the verification code to verify it. The verification code is randomly generated, and each time you transfer this page verification code will be refreshed.
Enter the verification code and submit, if the input verification code is consistent with the resulting verification code, then the registration is successful, otherwise the error message other requirement: the verification code is not caught, it is not easy to be detected by other programs Authorization.jsp ----- ----------------> Result.jsp involved the page authorizationImage.jsp displayed verification code, as a picture type exists on the authorization.jsp input verification code page Result.JSP results page The information submitted is submitted to the source code AuthorizationImage.jsp <% @ page contenttype = "image / jpeg" import = "java.awt. *, Java.awt.image. *, Java.util. *, Javax.imageio. * "%> <%! Color getrandcolor (int FC, int bc) {// given random color random random = new random (); if (fc> 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 (R , G, b);}%> <% // Settings page does not cache Response.setHeader ("Pragma", "NO-Cache"); Response.setHeader ("Cache-Control", "NO-Cache"); response .SetDateHeader ("expires", 0); // Create image in memory int width = 60 , Height = 20; BufferedImage image = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); // Get the graphics context Graphics g = image.getGraphics (); // class generating a random Random random = new Random (); // set Set Color G.SetColor (GetrandColor (200, 250)); G.FillRect (0, 0, Width, Height); // Set font G.SetFont (New Font ("Times New Roman", Font.Plain, 18) ); // Sea Box //g.SetColor (New Color ()); //g.drawRect (0, 10 ,width-1, Height 1); // Randomly generate 155 interference lines,
Make the authentication code in the image to be probed by other programs to G.SetColor (GetrandColor (160,200)); for (int i = 0; i <155; i ) {int x = random.nextint (width); int y = Random.nextint (Height); INT XL = random.nextint (12); int yl = random.nextint (12); g.drawline (x, y, x xl, y yl);} // Take the random production Certification code (4 digits) string srand = ""; for (int i = 0; i <4; i ) {string rand = string.valueof (Random.Nextint (10)); SRAND = rand; // Certification code is displayed in the image G.SetColor (New Color (20 random.nextint (110), 20 random.nextint (110))))); // Call the color from the function The same, may be because the seeds are too close, so only G. DrawString (RAND, 13 * i 6, 16) can only be generated;} // Deposit the authentication systattribute ("rand", srand); / / Image Effective g.dispose (); // Output Image to Page Imageio.write (Image, "JPEG", Response.getOutputStream ());%> Authorization.jsp <% @ Page ContentType = Text / HTML; Charset = GB2312 "%>