@zorner/captcha-generator
v1.0.2
Published
Modern captcha generator for Node.js using @napi-rs/canvas. Updated fork of the original captcha-generator package.
Maintainers
Readme
Captcha Generator
About
Captcha Generator is a Node.js library for quickly generating captcha images.
This package is a modern republish and update of the original project.
It now uses @napi-rs/canvas instead of the old node-canvas, which provides:
- Better compatibility with modern Node.js versions
- Faster native performance
- Easier installation (no complex system dependencies)
This updated package is published as:
@zorner/captcha-generatorInstallation
Install using npm:
npm install @zorner/captcha-generatoror with yarn:
yarn add @zorner/captcha-generatorUsage
Basic Example
const Captcha = require("@zorner/captcha-generator");
const captcha = new Captcha();
console.log("Captcha value:", captcha.value);Returned object properties:
| Property | Description | |--------|-------------| | PNGStream | PNG image stream | | JPEGStream | JPEG image stream | | dataURL | Base64 encoded JPEG image | | value | Captcha text (6 characters) |
Save Image to File
const fs = require("fs");
const path = require("path");
const Captcha = require("@zorner/captcha-generator");
const captcha = new Captcha();
captcha.PNGStream.pipe(
fs.createWriteStream(path.join(__dirname, `${captcha.value}.png`))
);Discord Bot Example
const Captcha = require("@zorner/captcha-generator");
function verifyHuman(msg) {
const captcha = new Captcha();
msg.channel.send({
content: "Enter the text shown in the captcha image:",
files: [{
attachment: captcha.JPEGStream,
name: "captcha.jpg"
}]
});
}Why this version?
The original project used node-canvas, which often caused installation issues because it required system-level dependencies.
This updated version uses @napi-rs/canvas, which:
- Supports modern Node.js versions
- Installs faster
- Works across Windows, Linux, and macOS without complex setup
Credits
Original project:
https://github.com/HaileyBot/captcha-generator
This package is a maintained and modernized fork using @napi-rs/canvas.
License
This project is licensed under the GPL-3.0 License.
