<commit_before># Captcha

Simple captcha.

## Installation

via npm:

	$ npm install captcha

## Application init:

	...
	var captcha = require('captcha');
	...
	app.configure(function(){
	...
		app.use(app.router);
		app.use(captcha('/captcha.jpg')); // url for captcha jpeg
		app.use(express.static(__dirname + '/public'));
	...

## Color Options

You can setup colors with an object, instead of just URL, like this (CSS-notation of color):

	...
	app.use(captcha({ url: '/captcha.jpg', color:'#0064cd', background: 'rgb(20,30,2}));
	...

All color options are optional.

## Render captcha:

	<img src="/captcha.jpg" />

## Check captcha:

	app.post('/user/create', function(req, res, next){
		if(req.body.captcha != req.session.captcha) // text from captcha stored into session
			return next(new Error('Captcha stop!'));
	...

PS: thanks for more detailed description: http://stackoverflow.com/questions/9487844/nodejs-how-to-use-node-captcha-module<commit_msg>usage doc<commit_after># Captcha

Simple captcha for Connect/Express.

## Installation

Via npm:

	$ npm install captcha

## Usage (for Express 3)

```javascript
var express = require('express');
var captcha = require('captcha');

var app = express();

app.configure(function(){
    app.use(express.bodyParser());
	app.use(express.cookieParser());
	app.use(express.cookieSession({ secret: 'keyboard-cat' }));
	app.use(captcha({ url: '/captcha.jpg', color:'#0064cd', background: 'rgb(20,30,200)' })); // captcha params
});

app.get('/', function(req, res){
	res.type('html');
	res.end('<img src="/captcha.jpg"/><form action="/login" method="post"><input type="text" name="digits"/></form>'); // captcha render
});

app.post('/login', function(req, res){
	res.type('html');
	res.end('CONFIRM: ' + (req.body.digits == req.session.captcha)); // captcha verify
});

app.listen(8080);
console.log('Web server started.');
```
{'fraction_non_alphanumeric': 0.19490175252257036, 'fraction_numerical': 0.016994158258098777, 'mean_word_length': 4.413793103448276, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3561493', 'n_tokens_mistral': 682, 'n_tokens_neox': 634, 'n_words': 147}