nycrite/captcha

This package is abandoned and no longer maintained. No replacement package was suggested.

An easy to use CAPTCHA generator for your verification needs.

dev-master 2023-11-18 22:35 UTC

This package is auto-updated.

Last update: 2025-05-19 01:47:35 UTC


README

The better way to make image CAPTCHAs.

Why?

As a last resort, I created my own CAPTCHA generator after not wanting to use Google's reCAPTCHA. Certainly, Google's CAPTCHAs are more reliable, but I wanted to make my own alternative for certain cases.

Usage

First, initalize the CAPTCHA generator as so:

$captcha = new Nycrite\Captcha\Captcha();
$image = $captcha->image();

Optionally, if you are using the CAPTCHA creator for forms (you most likely are), you can save it to a session.

$_SESSION['phrase'] = $captcha->phrase;

Next, output the image by encoding it in base64.

echo "<img src='data:image/png;base64," . base64_encode($image) . "' alt='captcha'>";