Socket
Socket
Sign inDemoInstall

svg-captcha

Package Overview
Dependencies
2
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svg-captcha

generate svg captcha in node.js or express.js


Version published
Weekly downloads
20K
decreased by-7.35%
Maintainers
1
Install size
1.01 MB
Created
Weekly downloads
 

Readme

Source

svg-captcha

svg captcha

Build Status

generate svg captcha in node.js

Translations

中文

useful if you

  • cannot or do not want to use google recaptcha
  • have issue with install c++ addon

install

npm install --save svg-captcha

usage

var svgCaptcha = require('svg-captcha');

var captcha = svgCaptcha.create();
console.log(c);
// {data: '<svg.../svg>', text: 'abcd'}

with express

var svgCaptcha = require('svg-captcha');

app.get('/captcha', function (req, res) {
	var captcha = svgCaptcha.create();
	req.session.captcha = captcha.text;
	
	res.set('Content-Type', 'image/svg+xml');
	res.status(200).send(captcha.data);
});

API

svgCaptcha.create(options)
If no option is passed, you will get a random string of four characters and corresponding svg.

options: object
{
  size: 4 // size of random string
  ignoreChars: '0o1i' // filter out some characters like 0o1i
  noise: 1 // number of noise lines
  color: true // characters will have distinct colors instead of grey, true if background option is set
  background: '#cc9966' // background color of the svg image
}

The previous options will be passed to the following functions svgCaptcha.randomText([size|options])
svgCaptcha(text, options) In pre 1.1.0 version you have to call these two functions,
now you can call create() to save some key strokes ;).

sample image

image

why use svg?

It does not require any c++ addon.
The result image is smaller than jpeg image.

This has to be a joke. /<text.+>;.+</text>/g.test...

svg captcha uses opentype.js underneath, which means that there is no '<text>1234</text>'.
You get '<path fill="#444" d="M104.83 19.74L107.85 19.74L112 33.56L116.13 19.74L119.15 19.74L113.48 36.85...'
instead.

Even though you can write a program that convert svg to png, svg captcha has done its job
—— make captcha recognition harder

License

MIT

Keywords

FAQs

Last updated on 06 Dec 2016

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc