A simple CAPTCHA service implementation.
Go to file
2023-08-12 22:39:42 +04:00
dwcaptcha Added /v2 in module name. 2023-08-12 22:39:42 +04:00
inmemdb Added /v2 in module name. 2023-08-12 22:39:42 +04:00
.gitignore Initial commit with a fully working program, lel. 2022-06-24 23:09:46 +04:00
captcha.go Simplified file structure. 2023-08-12 22:29:01 +04:00
db.go Simplified file structure. 2023-08-12 22:29:01 +04:00
go.mod Added /v2 in module name. 2023-08-12 22:39:42 +04:00
go.sum Removed code for a standalone executable. go min ver was downgraded to 1.12. 2023-08-12 22:23:52 +04:00
LICENSE Replace arav.top with arav.su. 2023-03-05 00:18:52 +04:00
README.md Removed code for a standalone executable. go min ver was downgraded to 1.12. 2023-08-12 22:23:52 +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 {
    ... // 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
...