PHPackages                             williamsampaio/simple-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. [Security](/categories/security)
4. /
5. williamsampaio/simple-captcha

ActiveLibrary[Security](/categories/security)

williamsampaio/simple-captcha
=============================

Simple class that implement a CAPTCHA for your PHP App

1.0.0(4y ago)16MITPHPPHP ^7.2

Since Nov 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/WilliamSampaio/simple-captcha)[ Packagist](https://packagist.org/packages/williamsampaio/simple-captcha)[ Docs](https://github.com/WilliamSampaio/simple-captcha)[ RSS](/packages/williamsampaio-simple-captcha/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (2)Used By (0)

simple-captcha
==============

[](#simple-captcha)

Simple class that implement a CAPTCHA for your PHP App.

[![GitHub](https://camo.githubusercontent.com/e4ebb3fcfaa03c3522287995a39ac37fec9e877cc2f5255058033decaa92edc8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f57696c6c69616d53616d7061696f2f73696d706c652d63617074636861)](https://camo.githubusercontent.com/e4ebb3fcfaa03c3522287995a39ac37fec9e877cc2f5255058033decaa92edc8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f57696c6c69616d53616d7061696f2f73696d706c652d63617074636861)[![GitHub release (latest SemVer)](https://camo.githubusercontent.com/ad18ba4196bafc0e0addbc651676e13e42d1a3d5691f3b7e343b73d4b7e220c8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f57696c6c69616d53616d7061696f2f73696d706c652d636170746368613f6c6f676f3d676974687562)](https://camo.githubusercontent.com/ad18ba4196bafc0e0addbc651676e13e42d1a3d5691f3b7e343b73d4b7e220c8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f57696c6c69616d53616d7061696f2f73696d706c652d636170746368613f6c6f676f3d676974687562)

Installation
------------

[](#installation)

Use the package manager [composer](https://getcomposer.org/) to install.

```
composer require williamsampaio/simple-captcha
```

Documentation
-------------

[](#documentation)

#### 1. Create new Captcha

[](#1-create-new-captcha)

```
 $captcha = new SimpleCaptcha();
```

If no parameters are passed the captcha code will be automatically generated with a length of 5 numeric characters.

But it is possible to pass two parameters. The first is a string with the captcha code (maximum length of 16 characters), the second is a boolean to generate random colors if true.

```
 $captcha = new SimpleCaptcha("H@ck3R'D_C0@r1", true);
```

#### 2. Get the captcha code

[](#2-get-the-captcha-code)

```
 $captcha->getKey();
```

#### 3. Get the captcha image

[](#3-get-the-captcha-image)

```
