A simple captcha for Node.js, support node 0.10.x, 0.12.x, 4.x and 5.0. Support Mac OS X and Linux.
Make sure install nodejs before building.
$ npm run build
$ npm run demo
Install ImageMagick before install naptcha on Linux.
$ apt-get install ImageMagick
$ npm install naptcha
express.js
var naptcha = require('naptcha').of();
app.get('/naptcha', function (req, res) {
var nap = naptcha.perform();
res.setHeader("Content-Type", "image/jpeg");
res.end(nap.bytes, 'binary');
});
koa.js
router.get('/naptcha', function* (req, resp) {
const nap = naptcha.perform();
this.session.naptcha = nap.text;
this.body = nap.bytes;
this.type = 'image/jpeg';
});
- 1.3.1
- stable version
- 2.0.0
- change api for get image bytes by
nap.bytes
- add cache for captcha
- change api for get image bytes by
- 2.0.3
- fix cache dispose issue
- stable version
MIT