All Projects → zxdong262 → canvas-captcha

zxdong262 / canvas-captcha

Licence: other
A simple captcha module for nodejs based on node-canvas

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to canvas-captcha

Captcha
Captcha for Laravel 5/6/7/8
Stars: ✭ 1,985 (+6303.23%)
Mutual labels:  captcha
Captcha Recognizer
基于C#.NET异步图形验证码识别组件(集成了若快、优优云、打码兔、云打码等平台,准确率95%,速度2-6秒)采用策略设计模式
Stars: ✭ 213 (+587.1%)
Mutual labels:  captcha
rotate-captcha
Rotate image captcha,旋转图片验证码
Stars: ✭ 50 (+61.29%)
Mutual labels:  captcha
Antiddos System
🛡️⚔️ Protect your web app from DDOS attack or the Dead Ping + CAPTCHA VERIFICATION in one line!
Stars: ✭ 173 (+458.06%)
Mutual labels:  captcha
Cintruder
Captcha Intruder (CIntrud3r) is an automatic pentesting tool to bypass captchas.
Stars: ✭ 192 (+519.35%)
Mutual labels:  captcha
Tlg joincaptchabot
Telegram Bot to verify if users that join a group, are humans. The Bot send an image captcha for each new user, and kick any of them that can't solve the captcha in a specified time.
Stars: ✭ 226 (+629.03%)
Mutual labels:  captcha
Decryptr
An extensible API for breaking captchas
Stars: ✭ 154 (+396.77%)
Mutual labels:  captcha
campto
Captcha package for nodejs.
Stars: ✭ 21 (-32.26%)
Mutual labels:  captcha
Friendly Challenge
The widget and docs for the proof of work challenge used in Friendly Captcha. Protect your websites and online services from spam and abuse with Friendly Captcha, a privacy-first anti-bot solution.
Stars: ✭ 207 (+567.74%)
Mutual labels:  captcha
12306 Captcha
基于深度学习的12306验证码识别
Stars: ✭ 254 (+719.35%)
Mutual labels:  captcha
Captcha break
验证码识别
Stars: ✭ 2,268 (+7216.13%)
Mutual labels:  captcha
Decaptcha
Recognize captcha by machine learning. 机器学习识别图片验证码(专门应付本科毕业设计)
Stars: ✭ 192 (+519.35%)
Mutual labels:  captcha
Easy12306
使用机器学习算法完成对12306验证码的自动识别
Stars: ✭ 2,674 (+8525.81%)
Mutual labels:  captcha
Hei.captcha
一个跨平台的图形验证码生成工具包/.net core
Stars: ✭ 172 (+454.84%)
Mutual labels:  captcha
JDMemberCloseAccount
学习python操作selenium的一个🌰 ,也是一种京东全自动退会方案
Stars: ✭ 1,235 (+3883.87%)
Mutual labels:  captcha
Gocaptcha
A captcha library written in golang
Stars: ✭ 154 (+396.77%)
Mutual labels:  captcha
Rnn ctc
Recurrent Neural Network and Long Short Term Memory (LSTM) with Connectionist Temporal Classification implemented in Theano. Includes a Toy training example.
Stars: ✭ 220 (+609.68%)
Mutual labels:  captcha
ulozto-captcha-breaker
Deep learning model using Tensorflow that breaks ulozto captcha codes.
Stars: ✭ 65 (+109.68%)
Mutual labels:  captcha
cs-wordpress-bouncer
CrowdSec is an open-source cyber security tool. This plugin blocks detected attackers or display them a captcha to check they are not bots.
Stars: ✭ 25 (-19.35%)
Mutual labels:  captcha
Imageocr
PHP验证码识别[PHP CAPTCHA Recognition]
Stars: ✭ 241 (+677.42%)
Mutual labels:  captcha

canvas-captcha

Build Status

a captcha module for nodejs based on node-canvas

note

  • install Cairo first, For system-specific installation view the Wiki from node-canvas
  • if you can see the captcha image, but empty, try another font your server has or install proper font pack in your server, such as sudo apt-get install ttf-mscorefonts-installer.

Installation

npm install canvas-captcha

use

//captcha 
let captcha = require('canvas-captcha')
let captchaOptions = {
  charPool: ('abcdefghijklmnopqrstuvwxyz' + 'abcdefghijklmnopqrstuvwxyz'.toUpperCase() + '1234567890').split('') //char pool Array
  ,size: {
    width: 100
    ,height: 32
  } //image size
  ,textPos: {
    left: 15
    ,top: 26
  } //text drawing start position
  ,rotate: .01 //text ratate
  ,charLength: 4 //how many chars
  ,font: '26px Unifont' //font size
  ,strokeStyle: '#0088cc' //style
  ,bgColor: '#eeeeee' //bg color
  ,confusion: true //draw another group background text to mangle the text
  ,cFont: '30px Arial' //bg text style
  ,cStrokeStyle: '#adc' //bg text color
  ,cRotate: -.05 //bg text rotate
}

//callback style
app.get('/captcha', function(req, res) {
  captcha(captchaOptions, function(err, data) {
    if(err) {
      res.send(err)
    }
    else {
      req.session.captcha = data.captchaStr
      res.end(data.captchaImg)
    }
  })
})

//use promise
let captchaPromise = function(options) {
  return new Promise(function(resolve, reject) {
    captcha(options, function(err, data) {
      if(err) reject(err)
      else resolve(data)
    })
  })
}

//in express
app.get('/captcha', function(req, res) {

  captchaPromise(captchaOptions)
  .then(function(data) {
    req.session.captcha = data.captchaStr
    res.end(data.captchaImg)
  }, function(err) {
    res.send(err)
  })

})

//in koa
app.get('/captcha', function* (next) {

  var data = yield captchaPromise(captchaOptions)
  this.session.captcha = data.captchaStr
  this.body = data.captchaImg

})

//or
app.get('/captcha', async ctx => {

  let data = await captchaPromise(captchaOptions)
  ctx.session.captcha = data.captchaStr
  ctx.body = data.captchaImg

})

test && example

git clone https://github.com/zxdong262/canvas-captcha.git
cd canvas-captcha
sudo npm install

# test
npm run test

# example
node test/app.js
# then visit http://127.0.0.1:5001

changelog

  • 2.1.0 use canvas 1.3.15, support node 6.2+
  • 2.0.1 use canvas 1.3.12, a little rewrite
  • 2.0.0 use canvas 1.2.9, compatible with nodejs v4
  • 1.2.8 use 'Unifont' as default font
  • 1.2.7 use 'system' as default font
  • 1.2.6 just fix readme koa example
  • 1.2.5 add some example to readme, use canvas version 1.2.1
  • 1.2.4 make err the first callback param
  • 1.2.3 use canvas version 1.1.6 version instead of version *

license

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].