icekristal/laravel-captcha

Laravel 验证码

v2.0.0 2024-03-07 08:27 UTC

This package is auto-updated.

Last update: 2024-09-07 09:33:52 UTC


README

安装

composer require icekristal/laravel-captcha

配置

php artisan vendor:publish --provider="Icekristal\LaravelCaptcha\CaptchaServiceProvider" --tag="config"

默认字体

php artisan vendor:publish --provider="Icekristal\LaravelCaptcha\CaptchaServiceProvider" --tag="fonts"

使用

获取所有信息。返回数组键:image_no_encode, image, secret_key

$arrayInfoCaptcha = \Icekristal\LaravelCaptcha\Facades\IceCaptcha::generateAndGetAllInfo();

设置设置

$image = \Icekristal\LaravelCaptcha\Facades\IceCaptcha::setLength(4)->setLevel(2)->generateAndGetAllInfo();

所有信息设置

setColorBackground('#000000');
setListColors(['#FFFFFF', '#0000FF', '#FF0000']);

获取仅未编码的图片

$captcha = \Icekristal\LaravelCaptcha\Facades\IceCaptcha::generate()->getImageNoEncode();

验证码检查

$requestData = explode("&&", Crypt::decryptString($this->get('captcha_secret')));
$requestData[0]; //text captcha
$requestData[1]; //timestamp captcha