nastaliq-captcha

2.0.0 • Public • Published

Nastaliq Captcha

A simple offline captcha in persian.

How to install

npm install --save nastaliq-captcha

How to use :

const express = require("express");
const Buffer = require("buffer").Buffer;
const { createCaptcha } = require("nastaliq-captcha");

const app = express();
const port = 4000;

app.get("/captcha", (req, res) => {
  const captcha = createCaptcha({
    width: 150,
    height: 50,
    from: 100,
    to: 999,
    lines: 3,
  });
  const number = captcha.number; // You can store it in a session and compare with user answer
  const image = new Buffer(captcha.image, "base64");

  res.writeHead(200, {
    "Content-Type": "image/png",
    "Content-Length": image.length,
  });

  res.end(image);
});

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);
});

Output :

captcha

Package Sidebar

Install

npm i nastaliq-captcha

Weekly Downloads

7

Version

2.0.0

License

ISC

Unpacked Size

1.09 MB

Total Files

6

Last publish

Collaborators

  • alirezakeshvari