1.0.4 • Published 2 years ago

typed-captchapng v1.0.4

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
2 years ago

Lite PNG captcha generator

More faster and colorful version of captchapng. (2~3 faster than orginal)

Added typings into captchapng2

Installation

npm install typed-captchapng

Examples

const http = require('http');
const captchapng = require('typed-captchapng');

http.createServer(function (req, res) {
  if(req.url == '/captcha.png') {
    let rand = parseInt(Math.random() * 9000 + 1000);
    let png = new captchapng(80, 30, rand); // width,height, numeric captcha

    res.writeHead(200, { 'Content-Type': 'image/png'});
    res.end(png.getBuffer());
  } else {
    res.end('');
  }
}).listen(8181);

console.log('Web server started.\nSee http:\\\\127.0.0.1:8181\\captcha.png');

output:

captcha