Using Java to make verification codes

Source: Internet
Author: User

Verification Code Introduction

The Verification Code (CAPTCHA) is"Completely Automated Public Turing test to tell Computers and humans Apart"the abbreviation for automatic distinguishing between computer and human Turing test is a public automatic program that distinguishes whether a user is a computer or a person. 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 word "captcha" was first invented in 2002 by Carnegie Mellon University's Louis·Feng·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 disorders, 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:

Static text verification Code

Mobile SMS Verification Code

Email Verification Code

Puzzle Verification Code

Mobile phone Voice Verification code

GIF dynamic picture Verification code

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. 650) this.width=650; "style=" font-family: ' The song Body '; Font-size:20px;color:rgb (1,1,1); "Name=" B9dc46a8-dcb9-4777-93d5-d6ae7797dfb9 "src=" https://app.yinxiang.com/shard/s14/nl/18380775/ af7b06c2-f171-436a-a1ac-35bed5335c0e/res/b9dc46a8-dcb9-4777-93d5-d6ae7797dfb9.jpg?resizesmall&width=832 " Width= "217" alt= "B9dc46a8-dcb9-4777-93d5-d6ae7797dfb9.jpg"/>


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 is a valid time of the general -seconds to theseconds, these are all for security. in theJavain thejava.awtThere are classes related to painting under the 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:650) this.width=650; "Name=" F06af006-c21f-4cc3-93b0-ee653379e1b3 "src=" https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/f06af006-c21f-4cc3-93b0-ee653379e1b3.jpg?resizesmall& width=832 "width=" 554 "alt=" f06af006-c21f-4cc3-93b0-ee653379e1b3.jpg "/>650" this.width=650; "src=" https:// app.yinxiang.com/shard/s14/nl/18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/ 8af47dbc-cf46-476c-b599-710254ec0b72.jpg?resizesmall&width=832 "width=" 554 "alt=" 8af47dbc-cf46-476c-b599-710254ec0b72.jpg "/>



Operation Result:

650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/4c0dfee0-9774-4cac-9c97-67543f693aed.jpg?resizesmall& width=832 "width=" 223 "alt=" 4c0dfee0-9774-4cac-9c97-67543f693aed.jpg "/>





Apply the verification code to the login verification:

Html code Example:

650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/45a63184-0a9f-4fa1-a444-c5e28cf8576c.jpg?resizesmall& width=832 "width=" 554 "alt=" 45a63184-0a9f-4fa1-a444-c5e28cf8576c.jpg "/>


Verification Code Servlet :

650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/4d7d7e13-3a25-4ce4-acda-1caaa1db4f14.jpg?resizesmall& width=832 "width=" 553 "alt=" 4d7d7e13-3a25-4ce4-acda-1caaa1db4f14.jpg "/>650" this.width=650; "Name=" F0ff3abd-c242-439f-ab73-07afc685cfa8 "src=" https://app.yinxiang.com/shard/s14/nl/18380775/ af7b06c2-f171-436a-a1ac-35bed5335c0e/res/f0ff3abd-c242-439f-ab73-07afc685cfa8.jpg?resizesmall&width=832 " Width= "553" alt= "F0ff3abd-c242-439f-ab73-07afc685cfa8.jpg"/>


processing of logged-on businessServlet:650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/2c7c6e4a-ab8f-41b5-b48f-6a07fca69ac2.jpg?resizesmall& width=832 "width=" 554 "alt=" 2c7c6e4a-ab8f-41b5-b48f-6a07fca69ac2.jpg "/>650" this.width=650; "src=" https:// app.yinxiang.com/shard/s14/nl/18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/ 14bedae0-6010-4630-92fc-7bc212d5b8b7.jpg?resizesmall&width=832 "width=" 553 "alt=" 14bedae0-6010-4630-92fc-7bc212d5b8b7.jpg "/>



Operation Result:

650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/43cef0b0-c4d5-4b50-9fce-a25c1eb71388.jpg?resizesmall& width=832 "Width=" 520 "alt=" 43cef0b0-c4d5-4b50-9fce-a25c1eb71388.jpg "/>



Console Print Results:

650) this.width=650; "style=" font-family: ' The song body '; font-size:20px; src= https://app.yinxiang.com/shard/s14/nl/ 18380775/af7b06c2-f171-436a-a1ac-35bed5335c0e/res/4c268079-c32f-413d-a5ae-cdf9a040d126.jpg?resizesmall& width=832 "width=" 329 "alt=" 4c268079-c32f-413d-a5ae-cdf9a040d126.jpg "/>


This article is from the "zero" blog, make sure to keep this source http://zero01.blog.51cto.com/12831981/1983314

Using Java to make verification codes

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.