UNPKG

@eternaljs/captcha

Version:

This npm package generates secure and customizable CAPTCHA images for web applications, preventing automated abuse with ease.

42 lines (28 loc) 1.12 kB
# Captcha 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. ## Installing Using npm: ```bash $ npm install @eternaljs/captcha ``` Using yarn: ```bash $ yarn add @eternaljs/captcha ``` ## Imports These examples assume you're in node, or something similar: ```javascript // JavaScript const generateCaptcha = require("@eternaljs/captcha"); // TypeScript import * as generateCaptcha from "@eternaljs/captcha"; ``` ## Usage Example ``` 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 ``` ## License MIT