PHPackages                             lifei6671/php-captcha - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. lifei6671/php-captcha

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

lifei6671/php-captcha
=====================

One php captcha

v0.1.1(9y ago)7422.8k↓50%17[2 issues](https://github.com/lifei6671/php-captcha/issues)MITPHPPHP &gt;=5.4

Since Jan 12Pushed 9y ago6 watchersCompare

[ Source](https://github.com/lifei6671/php-captcha)[ Packagist](https://packagist.org/packages/lifei6671/php-captcha)[ Docs](https://github.com/lifei6671/php-captcha)[ RSS](/packages/lifei6671-php-captcha/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-captcha
===========

[](#php-captcha)

简单的php验证码库。

PHP生成验证码图片
----------

[](#php生成验证码图片)

PHP生成验证码的原理：使用PHP的GD库，生成一张带验证码的图片，并将验证码保存在Session中。PHP生成验证码的大致流程有：

1、产生一张png的图片；

2、为图片设置背景色；

3、设置字体颜色和样式；

4、产生指定位数的随机的验证码；

5、把产生的每个字符调整旋转角度和位置画到png图片上；

6、加入噪点和干扰线防止注册机器分析原图片来恶意破解验证码；

7、输出图片；

8、释放图片所占内存。

图片实例
----

[](#图片实例)

[![1](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/1.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/1.png)[![2](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/2.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/2.png)[![3](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/3.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/3.png)[![4](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/4.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/4.png)[![5](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/5.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/5.png)[![6](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/6.png)](https://raw.githubusercontent.com/lifei6671/php-captcha/master/examples/image/6.png)

安装
--

[](#安装)

使用 Composer

```
{
    "require": {
            "lifei6671/php-captcha": "0.1.*"
    }
}
```

用法
--

[](#用法)

```
