# easy-captcha

> Easily add captcha to forms

Latest version **0.1.5** (published 2013-10-18) · BSD license · 0 weekly downloads

## Install

```sh
npm install easy-captcha
pnpm add easy-captcha
yarn add easy-captcha
bun add easy-captcha
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2013-10-18 |
| First published | 2013-10-16 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.5 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Yonatan Ellman |
| Maintainers | ellman |
| Keywords | captcha, forms |

## Links

- npm: https://www.npmjs.com/package/easy-captcha
- npm.io page: https://npm.io/package/easy-captcha

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2013-10-18
- 0.1.4 — 2013-10-16
- 0.1.3 — 2013-10-16
- 0.1.2 — 2013-10-16
- 0.1.1 — 2013-10-16
- 0.1.0 — 2013-10-16
- 0.0.9 — 2013-10-16
- 0.0.8 — 2013-10-16
- 0.0.7 — 2013-10-16
- 0.0.6 — 2013-10-16
- 0.0.5 — 2013-10-16
- 0.0.4 — 2013-10-16
- 0.0.3 — 2013-10-16
- 0.0.2 — 2013-10-16
- 0.0.1 — 2013-10-16

## README

easy-captcha tries to make integrating captcha into forms a simple and painless experience. 
## Installation

    $ npm install easy-captcha

## Features

  * Fast generation of captcha image based off of CCAP using c++
  * Middleware to check form submissions
  * Configure number of allowed attemps
  * Overide text generation function

## Basic Example using express and express.session

```js
var express = require('express');
var captcha = require('easy-captcha');

//intiate app
var app = express();

app.configure(function(){
    app.use(express.bodyParser());    
    //need to use sessions to store the captcha information
    app.use(express.cookieParser());
    app.use(express.session({ secret: 'some-secret' }));
    app.use('/captcha.jpg', captcha.generate());
    //Choose the path of the captcha image and intiate captcha with options
});

//sample form with the captcha image.
//the default name for the captcha text is captcha
app.get('/login', function(req, res, next){
		var form = ['<form action="/login" method="post">',
									'<img src="/captcha.jpg"/>',
								'<input type="text" name="captcha"/></form>'];
    res.send(form.join('\n'));
});

//use captcha.check as middleware to check the valid captcha result
app.post('/login', captcha.check, function (req,res,next) {
	//returns true is valid - the captcha value must sent in the captch field
	//the error message is in the errDesc key of the captcha object
	if (!req.session.captcha.valid) return res.send(401, "Captcha does not match");

	res.send("Captcha matched! Well done :)");
});

app.listen(7001);
```
## Configuration Options 

## Thanks
easy-captcha is based on CCAP node module. Many thanks

---
_Source: https://npm.io/package/easy-captcha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
