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 🙏

© 2024 – Pkg Stats / Ryan Hefner

leo-captcha

v1.0.11

Published

Simple, Easy yet Powerful Captcha Generator for Both Frontend and Backend

Downloads

4

Readme

Leo-Captcha

Simple, Easy, LightWeight yet Powerful captcha for your Website

Hello World I developed this module with the flexibility and simplicity that developers around the world need. I tried to minimise external dependencies and took the utmost care in searching for black holes and bugs. I have made use of Crypto Library of NodeJS to generate "SHA256"

// Import the module
const captcha = require("leo-captcha");

This module provides 4 types of CAPTCHA options,

  1. AlphaNumeric (Includes both Alphabets and Numbers)
  2. Alpha (Only Alphabets)
  3. Numeric (Only Numbers)
  4. Math (Simple Mathematical Equation of addition and subtraction)
// Generate Numeric Captcha.
var numeric = captcha.Captcha("Numeric");

// Generate AlphaNumeric Captcha.
var alphanumeric = captcha.Captcha("AlphaNumeric");

// Generate Alpha Captcha.
var alpha = captcha.Captcha("Alpha");

// Generate Math Captcha.
var math = captcha.Captcha("Math");

captcha.Captcha() function returns a JSON response containing 2 values i.e. hash Promise and captcha Data URL containing base64 Image of PNG format.

/**
 * Struct {
 *      hash: Promise<'hash of the captcha'>,
 *      captcha: "data:image/png,base64,...."
 * }
 */

numeric.hash.then((hash) => {
    // Save the Hash of Captcha to DB for later verification purpose
});

return numeric.captcha; // Use Data url for the captcha Image.

To verify weather the captcha entered by the user is correct or not, you can use the captcha.Verify() function which takes the User entered captcha along with hash value obtained while generating the captcha and callback functions.

// Verify use entered captcha.

successCB = () => {
    // Do things if the captcha Matchs
};
failureCB = () => {
    // Do things if the captcha Match fails.
};

captcha.Verify(User_Entered_Captcha, Hash_Stored_In_DB, successCB, failureCB);

Want to change the dimension of the captcha image?

// Set Dimensions of the Image => (width, height)
captcha.setDimension(200, 50);

Want to set a unique secret key that is used to salt the hash?

// Key used to salt and generate Hash
captcha.setSecret("Enter your unique Key Here.");

Do you what the captcha to have no or a specific background color?

// disable the background (Only White)
captcha.setBgColor(false);
// single background
captcha.setBgColor(true, ["#0f0"]);
// multiple background
captcha.setBgColor(true, ["#f00", "#0f0", "#00f"]);
// reset default
captcha.setBgColor();

Do you what the captcha to have no or a specific text color?

// disable color (Only Black)
captcha.setColor(false);
// single color
captcha.setColor(true, ["#0f0"]);
// multiple color
captcha.setColor(true, ["#f00", "#0f0", "#00f"]);
// reset default
captcha.setColor();

Do you what the captcha to be in one line or what them jumbled up and down? Keep values between -0.17 and 0.17 for optimal result

// disable the rotate (Inline)
captcha.setRotate(false);
// single type rotate
captcha.setRotate(true, [0.025]);
// multiple type rotate
captcha.setRotate(true, [-0.025, 0, 0.025]);
// reset default
captcha.setRotate();