Usage
Generating a captcha
const Captcha = require("gimpy-captcha");
const captchaConfig = {
mode: "math",
cryptoKey: "ezrvvv",
signatureKey: "man0lett3",
noise: 20,
};
function generateCaptcha() {
const captchaConfig = Captcha.CaptchaConfigManager.default(captchaConfig);
const captcha = Captcha.create(captchaConfig);
return {
captchaSvg: captcha.captchaSvg,
captchaExpression: captcha.expr,
encryptedCaptchaExpression: captcha.encryptedExpr,
};
}
Verifying a captcha
const Captcha = require("gimpy-captcha");
function verify(encryptedCaptchaExpression, captchaSolution) {
const captchaResult = Captcha.verify(
captchaExpression,
captchaSolution,
"ezrvvv"
);
return captchaResult;
}
Testing
npm run test
or
npm run test:tdd