hnllyrp/laravel-captcha is a Laravel package for the captcha package for laravel.
It currently has 0 GitHub stars and 3 downloads on Packagist (latest version v1.0.0).
Install it with composer require hnllyrp/laravel-captcha.
Discover more Laravel packages by hnllyrp
or browse all Laravel packages to compare alternatives.
Last updated
The captcha package for laravel 图形验证码
支持多种类型 数字字母验证码,算术验证码,中文验证码
支持在不同的页面使用(须配置不同的类型)
支持 api 接口使用
composer require hnllyrp/laravel-captcha
config/captcha.php
<!-- captcha.blade.php -->
<input type="text" id="captcha" name="captcha" />
<img src="{{captcha_src()}}" onclick="this.src='{{captcha_src()}}'+Math.random()"/>
// 验证
$type = $request->input('type', 'default');
$validator = Validator::make($request->all(), [
'captcha' => ['required', 'captcha:' . $type],
]);
// 或使用输助函数
if(!captcha_check($type, $value)){
// 验证失败
}
$.get("api/captcha",{}, function(data){
var captcha = data.captcha; // base64图片
var hash = data.hash; // 验证hash,验证接口须带上此参数
$("#captcha_img").src(captcha);
});
// 前端需要把验证码的值与 hash值 去请求 后续的验证接口
// 后端接口验证
$type = $request->input('type', 'default');
$hash = $request->input('hash');
$validator = Validator::make($request->all(), [
'captcha' => ['required', 'captcha_api:' . $type . ',' . $hash],
]);
// 或使用输助函数
if(!captcha_api_check($type, $value, $hash)){
// 验证失败
}