【文件属性】:
文件名称:PHP的图形验证码库.zip
文件大小:591KB
文件格式:ZIP
更新时间:2022-07-31 04:28:37
类库下载-PHP的图形验证码库
<?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";先用户权限登录模块的时候,我们会经常使用到验证码。今天给大家推荐一个验证码类库方便日后的使用。生成验证码的步骤大概就是:一)产生一个随机的字符串;二)创建一个图像(imagecreatetruecolor),然后将字符串输出到图像中(imagestring或者imagettftext);三)对图像进行噪点干扰,比如加入一些线条或者像素点(imageline和imagesetpixel)。四)输出图像(imagepng)五)销毁图像资源
【文件预览】:
PHP的图形验证码库
----src()
--------Gregwar()
----phpunit.xml.dist(381B)
----php中文网下载站.url(114B)
----demo()
--------ocr.php(710B)
--------output.php(186B)
--------fingerprint.php(181B)
--------demo.php(171B)
--------index.php(359B)
----.travis.yml(159B)
----LICENSE(1KB)
----README.md(4KB)
----php中文网免费下载站.txt(219B)
----tests()
--------CaptchaBuilderTest.php(568B)
----.gitignore(41B)
----composer.json(803B)