30 lines
518 B
Go
30 lines
518 B
Go
|
package captcha
|
||
|
|
||
|
import (
|
||
|
"image"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var captchaDb CaptchaDB = CaptchaDB{
|
||
|
DB: make(map[ID]ICaptcha)}
|
||
|
|
||
|
func Init(expiration time.Duration) {
|
||
|
captchaDb.SetExpiration(expiration)
|
||
|
}
|
||
|
|
||
|
func New(data string, captcha ICaptcha) (ICaptcha, ID) {
|
||
|
return captchaDb.New(data, captcha)
|
||
|
}
|
||
|
|
||
|
func Image(id ID) (*image.Image, error) {
|
||
|
return captchaDb.Image(id)
|
||
|
}
|
||
|
|
||
|
func Solve(id ID, answer Answer) (bool, error) {
|
||
|
return captchaDb.Solve(id, answer)
|
||
|
}
|
||
|
|
||
|
func IsSolved(id ID) (bool, error) {
|
||
|
return captchaDb.IsSolved(id)
|
||
|
}
|