justcaptcha/README.md

36 lines
729 B
Markdown
Raw Normal View History

2023-08-12 22:12:49 +04:00
justcaptcha
===========
A simple CAPTCHA implementation.
An example using built-in "dwelling" implementation.
Create a new CAPTCHA:
c := dwcaptcha.NewDwellingCaptcha(expiry)
_, id := inmemdb.New(someAdditionalDataUsedInIDGenerationUsuallyIPAddr, c)
Get an image for a CAPTCHA:
i := inmemdb.Image(captchaID, captchaStyle)
if i == nil {
2023-05-06 04:49:57 +04:00
... // do something if there was no image returned
}
jpeg.Encode(w, *i, &jpeg.Options{Quality: 20})
Solve a CAPTCHA:
if ok := inmemdb.Solve(captchaID, answer); !ok {
... // not solved
}
// solved
...
Check is CAPTCHA was solved:
if ok := inmemdb.IsSolved(captchaID); !ok {
... // not solved
}
// solved
...