V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
AutumnVerse
V2EX  ›  PHP

想找一个 PHP 的验证码库

  •  
  •   AutumnVerse · Oct 26, 2021 · 2898 views
    This topic created in 1652 days ago, the information mentioned may be changed or developed.

    最近做一个表单提交,需要加个验证码,我也知道这年头流行什么滑块,找位置,可是我不需要那么复杂就简简单单生成个图片验证码。然鹅找了好久好久,竟然找不到一个像样点的验证码库了。我去

    我记忆中(大概 7 8 年前了吧)有一个验证码库,可以很方便的自定义尺寸、背景、干扰线数量、字体、扭曲等等参数,但是现在怎么找都找不到了。生成出来的验证码图片大概长这个样子,还有没有哪个老哥记得这个库叫啥呀

    img

    8 replies    2021-11-15 12:50:04 +08:00
    sytnishizuiai
        1
    sytnishizuiai  
       Oct 26, 2021
    不用库吧,这个就一个 php 文件,你搜 php 验证码一堆。
    ajaxfunction
        2
    ajaxfunction  
       Oct 26, 2021
    composer require topthink/think-captcha=2.0.*


    $config = [
    // 验证码字体大小
    'fontSize' => 30,
    // 验证码位数
    'length' => 3,
    // 关闭验证码杂点
    'useNoise' => false,
    ];
    $captcha = new Captcha($config);
    return $captcha->entry();
    ywisax
        3
    ywisax  
       Oct 26, 2021
    gregwar/captcha
    thinkerDev
        4
    thinkerDev  
       Oct 27, 2021
    guanguans
        5
    guanguans  
       Oct 27, 2021
    推荐: https://github.com/Gregwar/Captcha ,个人基于这个包开发过一个 dcat-admin 的登录验证码扩展: https://github.com/guanguans/dcat-login-captcha
    veike
        6
    veike  
       Oct 27, 2021 via Android
    直接写一个不行吗,多简单啊
    elfsundae
        7
    elfsundae  
       Oct 31, 2021 via iPhone
    zzfly256
        8
    zzfly256  
       Nov 15, 2021   ❤️ 1
    要简单实用的话,这个就够: https://github.com/php-quickorm/Captcha


    composer require php-quickorm/captcha

    ------------------

    image.php

    $captcha = new Captcha();
    $_SESSION['code'] = $captcha->getCode();
    $captcha->render();

    ------------------

    index.html

    <img src="image.php">
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3259 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 13:08 · PVG 21:08 · LAX 06:08 · JFK 09:08
    ♥ Do have faith in what you're doing.