Shashank3736 / captcha-canvas

A captcha generator by using skia-canvas.
https://captcha-canvas.js.org
Apache License 2.0
61 stars 11 forks source link

I want to generate a random UpperCase / LowerCase captcha how do I do that #24

Closed PiinnKs closed 3 years ago

PiinnKs commented 3 years ago
    const captchacode = crypto.randomBytes(32).toString("hex").substr(0, 4);
    const captcha = new CaptchaGenerator() 
    .setCaptcha({text: captchacode, size: 60, color: '#e600ff'})
    .setTrace({color: '#e600ff', size: 6});
    const buffer = await captcha.generate(); 
Shashank3736 commented 3 years ago

You can generate captcha text by using crypto.

Docs: https://nodejs.org/dist/latest-v14.x/docs/api/crypto.html#crypto_crypto_randombytes_size_callback