koa-canvas-captcha
适用于Koa框架的canvas绘制的验证码库
Install
npm install koa-canvas-captcha --save
Demo
var captcha = ; var path = ;var { //生成验证码 返回text和图buffer var item = ; //将验证码答案存在session thissessioncaptcha = itemanswer; //返回图片 thistype = 'jpg'; this; thisbody = itemimageBuffer };
Options
length
- (Number ) captcha lengthfontSize
- (Number | default: 30 ) captcha font sizewidth
- (Number | default: 150) image widthheight
- (Number | default: 32) height widthlineWidth
- (Number | default: 1) background line widthbackground
- (String | default: rgb(255,255,255)) background colorcolor
- (String | default: rgb(0,0,0)) font colortext
- (String) custom captcha textfontPath
- (String ) the *.ttf file pathtype
- (String | default: normal) captcha typenormal
- random letter and numberletter
- just letternumber
- just numberarithmetic
- random arithmetic
Result
text
- the words on the captchaanswer
- the answer should inputimageBuffer
- imageBuffer