bnb930125/think-captcha

captcha package for thinkphp

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

pkg:composer/bnb930125/think-captcha

v1.0.0 2025-05-30 03:03 UTC

This package is not auto-updated.

Last update: 2025-12-27 04:49:12 UTC


README

thinkphp 验证码类,基于 thinkphp 官方 think-captcha 修改。用于前后端分离项目,用 cookie 保存 captcha 信息,不依赖 session 。\ 修改了图片生成算法。更换了字体。\ 代码仓库: https://gitee.com/bnb930125/think-captcha.git

安装

composer require bnb930125/think-captcha

使用

在控制器中输出验证码

public function captcha()
{
  return captcha();
}

校验验证码

if(!captcha_check($input)){
  //验证码错误
}

API 方式使用

use bnb930125\captcha\facade\Captcha;

// 输出
$captchaInfo = Captcha::create(null, true);
// $captchaInfo['img'] 包含 base64 格式图片信息。

// 检验
if(!Captcha::check($input,$captchaInfo['hash'])){
  // 验证码错误
}