npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eazycaptcha

v0.0.7

Published

一个验证码基础库

Readme

A simple captcha generator

Dependencies: node version ^16.14.2, canvas: ^2.11.2

Installation

npm i eazyCaptcha

Note

If you encounter an error while installing canvas:

npm ERR! path /home/des/Desktop/verificationCode/node_modules/canvas
npm ERR! command failed
npm ERR! signal SIGINT
npm ERR! command sh -c node-pre-gyp install --fallback-to-build --update-binary

You can try the following command:

npm install canvas --canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas

Usage

import { generateCode, validate, codeConfig, CodeType, codeResult } from './index';

If you need a different type of captcha, you can modify the parameters based on the default template below:

const config = { 
    codeType: <codeType>'character', // Type of captcha: text (default) 'character', calculation 'calculate', dragging 'slide', clicking 'click'
    characterString: <string>'', // Captcha string or character array. If not provided, a random set will be generated. Can be Chinese, English, numbers, or special characters. For the 'click' type, it is the text displayed above.
    codeSize: <number>'300*150', // Captcha size. Supports formats '200*100' and '200x100'
    matchCase:<boolean>true,//`character`Case sensitive or not
    rangeValue:<number>20,//`slide`、`click`Fault-tolerant value
    characterLength: <number>4, // Length of characters (except for 'slide')
    rotationAngle: <number>0, // Rotation angle. Default is '0'. Can be selected between '1' and '-1'. Recommended not to exceed this range. Only valid for 'character' and 'calculate'.
    disturbingLinesNumber: <number>3, // Number of disturbing lines. Only valid for 'character' and 'calculate'.
    codeBackImage: <string>'#fff', // Background image or color of the captcha. Supports all standard color values. If it's a 'slide' or 'click' captcha, an **image URL** must be provided.
    saveOrNot: <boolean>true, // Whether to save the rendered captcha locally. It will be saved in the 'verificationCode' folder.
    colorGroup: <string[]|string>['#dc3545', '#0dcaf0', '#ffc107', '#198', '#0d6efd'] // Text color group. Can be an array or a single color value. Supports all standard color values.
}
// You can call the function without any parameters to generate a set of text captcha
generateCode(config).then((res: any) => {
    console.log(res.verificationCodeHex, 'res');
}).catch((err)=>{
    console.log(err,'err');
})

Output structure of the 'res' object:

{
    // Captcha content. If it's not a dragging captcha, it's the base64 content of the captcha. Otherwise, it's an object.
    verificationCode: string | {
        // Base64 content of the background layer
        break: string,
        // Content of the dragging layer
        front: string,
        // Difference in height between the top left corner of the dragging layer and the top left corner of the background layer
        startHeight: number,
    },
    // Captcha size
    codeSize: string,
    // Unique hash value of the captcha (used to check if it passes the verification)
    verificationCodeHex: string,
    // Whether the captcha is successfully generated
    status: boolean,
    // Type of captcha
    codeType: CodeType
}

Conduct verification

//You need to pass in the unique hex value of the verification code to verify the content
 validate(result.verificationCodeHex, value).then(val => {
            console.log(val);
        }).catch(err => {
            console.log(err);
        })

Validated return value

{
    status:boolean,//Verify success
    hex:string//Unique hash value
}