Use Java to make text verification code

Source: Internet
Author: User
Tags html code example

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

Verification Code Introduction

verification code (CAPTCHA) Yes The abbreviation for "Completely Automated public Turing test to tell Computers and humans Apart" (fully automated computer-differentiated and human Turing test) is a common, fully automated program that distinguishes whether a user is a computer or a human being. Can prevent: Malicious hack password, brush tickets, forum irrigation, effectively prevent a hacker to a particular registered users with a specific program brute force to make a continuous attempt to break the way, in fact, with the verification code is now a lot of web site way, we use a relatively simple way to achieve this function. This problem can be generated and judged by a computer, but only humans can answer it. Since the computer is unable to answer the CAPTCHA question, the user who answers the question can be considered human. The term
Captcha was first introduced in 2002 by Louise Feng Ann of Carnegie Mellon University, Manuel Blum, Nicholas J.hopper, and John Langford of IBM. Carnegie Mellon University has tried to apply the term to make it a registered trademark, but the application was rejected on April 21, 2008. A commonly used CAPTCHA test is to allow the user to enter a distorted picture of the text or number displayed on the image, that is, graphic verification code, distortion is to avoid the optical character recognition (OCR, Optical Character Recognition) such as computer programs automatically identify the image of the text numbers and lose the effect. Since the test was made by a computer to test humans, rather than by humans in the standard Turing Test, people sometimes called captcha a reverse Turing test.
in order to not see the image of the physical and mental disabilities, the alternative is to use the voice to read out the text number, in order to prevent speech recognition analysis sound, the content of the sound will have a noise, this is the phone voice verification code, by dialing the phone to tell the user what the verification code.

Current verification code types are common:
1. Static Text Verification code
2. Mobile SMS Verification Code
3.Email Verification Code
4. Puzzle Verification Code
5. Mobile phone Voice Verification code
6.GIF Dynamic Image Verification code
7. Video Verification Code

Text Verification Code

It can be said that the earliest appearance of the verification code is a text verification code, but also the most common form of verification code.

Verification code is generated from the server and sent to the client, the verification code is not to apply a ready-made picture, but in the server-side memory temporarily generated, and usually generated and sent to the client after the deletion, in addition to the verification code has a valid time is generally 60 seconds to 360 seconds, these are to ensure security.
In Java, there are classes related to painting under the java.awt package, and using these tools, you can generate simple text verification codes.
Here's a demonstration of how to generate a simple captcha using the actual code:

Operation Result:

Apply the verification code to the login verification:
HTML code example:

CAPTCHA servlet:

To process a servlet that logs on to a business:

Operation Result:

Console Print Results:

Use Java to make text verification code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.