📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

captchar

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

captchar

Generate captcha image. Written in Node.js.

0.2.0
latest
Source
npm
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

Captchar

Node version NPM version Dependency Status

Generate captcha image. Written in Node.js.

Installation

Node-captchar requires canvas, pleace follow canvas's installation wiki to install dependencies.

Features

  • Background noises
  • Support dummy character (presented in red color)
  • Customizable string pool

Usage

var captchar = require('captchar')

captchar()
    .then(function (data) {
        console.log(data)
    })
/*
{
    src: '/PATH/TO/PROJECT/.captchar/73f1b787f3f125d8091b3a640343d4de.png,
    code: 'TyK2'
}
 */

captchar({ format: 'datauri' })
    .then(function (data) {
        console.log(data)
    })
/*
{
    src: 'data:image/png',
    code: '5HPp'
}
 */

captchar({ format: 'stream' })
    .then(function (data) {
        console.log(data)
    })
/*
{
    src:
        {
            sync: undefined,
            canvas: [Canvas 80x30],
            readable: true,
            _events: {}
        },
    code: 'jF4i'
}
 */

Options

captchar({
    width: 80,
    height: 30,
    fontSize: 22,
    fontFamily: 'Times New Roman',
    textLength: 4, // dummy character is not included
    backgroundColor: '#fff',
    outputDir: process.cwd()) + '/.captchar/',
    imageName: md5(Date.now().toString())) + '.png', // do not pass .png; recommend to generate image name manually
    format: 'fs', // 'stream', or 'datauri'. otherwise, out to `disk`
    pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
    dummy: true // set to `false` to turn dummy off
})

Example with default options:

The real code is 5HPp, o is dummy.

Contributors

FAQs

Package last updated on 02 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts