yzh52521/webman-captcha

captcha package for webman plugin

v0.1.6 2023-04-27 09:58 UTC

This package is auto-updated.

Last update: 2024-11-27 13:08:41 UTC


README

webman 验证码类库 支持前后端分离,api接口调用

安装

composer require yzh52521/webman-captcha

使用

public function captcha()
{
   return yzh52521\captcha\facade\Captcha::create();
}

生成结果

{
  "key": "Qh8kHYF4C....",//验证码key
  "value": "data:image/jpeg;base64,/9j/...."//base64验证码图片 -- 前端渲染显示
}

验证

if (!yzh52521\captcha\facade\Captcha::check($data['verify'], $data['key'])) {
   throw new \Exception('验证码错误');
}