A simple CAPTCHA service implementation.
dwcaptcha | ||
inmemdb | ||
.gitignore | ||
captcha.go | ||
db.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
README.md |
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 {
... // 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
...