The "captcha" npm package provides a straightforward solution for generating secure and customizable CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) images for use in web applications. CAPTCHAs are widely employed to prevent automated abuse, such as spamming or unauthorized access, by verifying that the user is a human rather than a bot.
Using npm:
$ npm install @eternaljs/captcha
Using yarn:
$ yarn add @eternaljs/captcha
These examples assume you're in node, or something similar:
// JavaScript
const generateCaptcha = require("@eternaljs/captcha");
// TypeScript
import * as generateCaptcha from "@eternaljs/captcha";
const captcha = generateCaptcha({ width: 180, height: 50 })
console.log(captcha.text); // Outputs a random alphanumeric code of the specified length
console.log(captcha.image.toBuffer()); // Returns an Image Buffer
console.log(captcha.image.toDataURL()); // Returns an Image base64 data url
MIT