Type npm i simple-captcha-generator
in your cmd to install the package
const { Captcha } = require("simple-captcha-generator");
const captcha = new Captcha();
const { Captcha }= require('simple-captcha-generator');
let captcha = new Captcha();
(async () => {
console.log(captcha.currentString);
console.log(await captcha.image(captcha.currentString));
})();
You can have have a min length of 5
and a max length of 10
. When no length is specified it will default to 5. Every length above 10 will default to 10.
const captcha = new Captcha(5);
.currentString string
Returns a generated string with the given length
Example: '0e6ji'
.length int
Returns the given length
Example: 8
.image() Buffer
Returns and image buffer of the generated captcha (Promise so use await!)
Usage
captcha.image(captcha.currentString) //Return image buffer of current generated string