1.0.0 • Published 6 years ago

node-pure-captcha v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

nodecaptcha

pure nodejs captcha

//eg
//for koa 
var VerifyImage=require("./index.js");
module.exports=async (ctx,next)=>{
    await next();
    var vImage=new VerifyImage();
    vImage.init();
    var code=vImage.create();
    //保存code 到session 以待使用
    ctx.body=vImage.output();
};

//a test

const VerifyImage=require("./index.js");
const fs=require("fs");
var img=new VerifyImage();
img.init();
var code=img.create();
console.log('生成的验证码是:',code);
var bf=img.output();

fs.writeFile("code.gif",bf,function(){
    console.log('保存验证码图片到code.gif');
});