think-svg-captcha

svg captcha for ThinkJS

Usage no npm install needed!

<script type="module">
  import thinkSvgCaptcha from 'https://cdn.skypack.dev/think-svg-captcha';
</script>

README

think-svg-captcha

Build Status Coverage Status npm

think-svg-captcha is just a wrap of svg-captcha.

Usage

default options

const defaultOptions = {
  size: 4, // size of random string
  ignoreChars: '', // filter out some characters
  noise: 3, // number of noise lines
  color: false, // default grey, true if background option is set
  background: '#ffffff', // background color of the svg image
  width: 150, // width of captcha
  height: 50, // height of captcha
  fontPath: './fonts/Comismsh.ttf', // your font path
  fontSize: 32, // captcha text size
  charPreset: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' // random character preset
}

demo

import ThinkSvgCaptcha from 'think-svg-captcha';
let captcha = new ThinkSvgCaptcha(options);

captcha.create(); // returns an object that has the following property: {data: 'svg path data', text: 'captcha text'}
captcha.svgCaptcha(text); // return a svg captcha based on text provided.

You can find more details at svg-captcha !