Get the App
SLTechnology News&Howtos  ›  Development  › 

How to generate background CAPTCHA with Java

Shulou Source: shulou.com Published: 2022-06-01 11:48:23 11月12日 Update

This "Java how to achieve background CAPTCHA generation" article most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "Java how to achieve background CAPTCHA generation" article bar.

1. Applicable demand

The background generates the verification code, which is used for login verification.

two。 Controls / files required for functional implementation:

None (normal label)

3. The idea of function point realization

1) Front desk ideas:

(1) one at the front desk is used to enter the CAPTCHA; one

Used to display CAPTCHA.

(2) the CAPTCHA is generated and displayed. Click the refresh function to

Bind the click event.

(3) the ajax request is written in the click event, and the processed CAPTCHA image with noise is generated through the background.

Note: the background directly returns the picture, not the character of the CAPTCHA! If the character is returned, the CAPTCHA will lose its meaning (the CAPTCHA character can be easily obtained by the foreground, and the CAPTCHA character can be accessed maliciously many times) (this takes into account the system security)

(4) about how the returned picture is displayed in the

In-label display

Directly use the src attribute of img, and the attribute value is the request path for the method of generating CAPTCHA in the background. When you click the CAPTCHA, you can dynamically set the src attribute (original access address + random timestamp to prevent the same path browser from visiting separately)

Front desk part of the code:

/ * CAPTCHA input box * / / * CAPTCHA picture * /

Tags: Validation background generation picture content foreground function character idea code property method codeword interference event address file article tag browser Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info OPPO Reno Docker Linux