<?php require_once __DIR__.'/../vendor/autoload.php'; use Gregwar\Captcha\CaptchaBuilder; $tests = 10000; $passed = 0; shell_exec('rm passed*.jpg'); for ($i=0; $i<$tests; $i++) { echo "Captcha $i/$tests... "; $captcha = new CaptchaBuilder; $captcha ->setDistortion(false) ->build() ; if ($captcha->isOCRReadable()) { $passed++; $captcha->save("passed$passed.jpg"); echo "passed at ocr... "; } else { echo "failed... "; } echo "pass rate: ".round(100*$passed/($i+1),2)."%\n"; } echo "\n"; echo "Over, $passed/$tests readed with OCR\n";
When logging in to the module with user permissions first, we will often use verification codes. Today I would like to recommend a verification code library for your future use.
The steps to generate a verification code are roughly:
1) Generate a random string;
2) Create an image (imagecreatetruecolor), and then output the string to In the image (imagestring or imagettftext);
3) Interfere with noise in the image, such as adding some lines or pixels (imageline and imagesetpixel).
4) Output image (imagepng)
5) Destroy image resources
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
13Jul2023
Tips for generating simple graphical verification codes using PHP and GD libraries. With the development of the Internet, preventing malicious attacks and abuse has become an indispensable part of website development. CAPTCHA is a technical means widely used to verify user identity and prevent malicious robots from registering and logging in. As a popular server-side programming language, PHP, combined with the GD library, can quickly generate simple graphical verification codes. 1. Introduction to GD library The GD library is an extension library of PHP. It provides a series of functions and methods for processing images. Through the GD library,
14Jul2023
Tips for generating colorful verification code images using PHP and GD libraries Introduction: Verification code is a common network security technology. By requiring users to enter a verification code when logging in, registering, or submitting a form, you can effectively prevent automated attacks from robots and malicious programs. This article will introduce the techniques of using PHP and GD libraries to generate colorful verification code images, helping developers to add a certain degree of recognizability and artistry when creating verification codes. 1. Environment preparation Before starting, make sure that PHP and GD libraries have been installed in your development environment. Can
13Jul2023
Detailed steps for generating verification code images using PHP and GD libraries Verification codes are a commonly used security verification mechanism that can be used to prevent malicious programs or robot automation. Automated attacks can be effectively prevented by generating a random image that requires users to enter the verification code shown in the image when logging in or registering. In this article, we will introduce in detail how to use PHP and GD library to generate verification code images. Step 1: Install and configure the GD library First, make sure your PHP environment has the GD library installed. If not installed
11May2023
With the development of the Internet, more and more websites need to use verification codes to prevent malicious registration, crawlers and other behaviors. Image verification code is a common form of verification code. It displays an image containing random characters or numbers, allowing users to enter the correct verification code before proceeding to the next step. This article will introduce how to use PHP and GD library to generate image verification codes. The GD library is an image processing library that can be used to generate, process and manipulate various image formats. PHP already has a built-in GD library and provides many functions for creating and manipulating graphs
25Jul2016
Example of php verification code (GD library generates verification code)
20Oct2021
In the previous article, I brought you "How to draw polygons, arcs and ellipses in PHP?" (Detailed Explanation with Graphics and Text)", which introduces in detail how to draw graphics in PHP. In this article, we will take a look at how we generate graphic verification codes in PHP. I hope everyone has to help!
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images