Documentation
¶
Index ¶
- Constants
- Variables
- type AudioFormat
- type ImageFormat
- type Language
- type PhraseCaptcha
- type PhraseCaptchas
- func (pcs *PhraseCaptchas) Check(captchaID [16]byte) error
- func (pcs *PhraseCaptchas) Get(captchaID [16]byte) (pc *PhraseCaptcha)
- func (pcs *PhraseCaptchas) GetAudio(captchaID [16]byte, lang Language, audioFormat AudioFormat) (pc *PhraseCaptcha)
- func (pcs *PhraseCaptchas) NewImage(lang Language, imageformat ImageFormat) (pc *PhraseCaptcha)
- func (pcs *PhraseCaptchas) Solve(captchaID [16]byte, answer string) error
Constants ¶
View Source
const ( StateCreated state = iota StateLastAnswerNotValid StateSolved )
Captcha State
Variables ¶
View Source
var ( ErrCaptchaNotFound = errors.New("CaptchaNotFound", "Given CaptchaID point to the captcha that not exist") ErrCaptchaExpired = errors.New("CaptchaExpired", "Given CaptchaID point to the captcha that expired") ErrCaptchaAnswerNotValid = errors.New("CaptchaAnswerNotValid", "Given answer for captcha not valid") ErrCaptchaNotSolved = errors.New("CaptchaNotSolved", "Given CaptchaID point to the captcha not solved yet, Solve it before use it to prove human being") )
package errors
Functions ¶
This section is empty.
Types ¶
type ImageFormat ¶
type ImageFormat uint8
ImageFormat indicate
const ( ImageFormatPNG ImageFormat = iota ImageFormatJPEG )
Supported image format
type PhraseCaptcha ¶
type PhraseCaptcha struct {
ID [16]byte
Answer string
ExpireIn int64
State state
Image []byte // In requested lang & format
Audio []byte // In requested lang & format
}
PhraseCaptcha store
type PhraseCaptchas ¶
type PhraseCaptchas struct {
Len uint8 // Number of captcha solution. can't be more than 16!
Difficulty uint8 // 0:very-easy, 1:easy, 2:medium, 3:hard, 4:very-hard, 5:extreme-hard
Type uint8 // 0:Number(625896), 1:Word(A19Cat), 2:Math(+ - * /),
Duration int64 // The number of seconds indicate expiration time of captchas
ImageSize image.Point // Standard width & height of a captcha image.
Pool map[[16]byte]*PhraseCaptcha
// contains filtered or unexported fields
}
PhraseCaptchas store
func NewDefaultPhraseCaptchas ¶
func NewDefaultPhraseCaptchas() (pcs *PhraseCaptchas)
NewDefaultPhraseCaptchas use to make new captchas with defaults values!
func (*PhraseCaptchas) Check ¶
func (pcs *PhraseCaptchas) Check(captchaID [16]byte) error
Check return true if captcha exits and solved otherwise returns false!
func (*PhraseCaptchas) Get ¶
func (pcs *PhraseCaptchas) Get(captchaID [16]byte) (pc *PhraseCaptcha)
Get return exiting captcha if exits otherwise returns nil!
func (*PhraseCaptchas) GetAudio ¶
func (pcs *PhraseCaptchas) GetAudio(captchaID [16]byte, lang Language, audioFormat AudioFormat) (pc *PhraseCaptcha)
GetAudio return exiting captcha with audio generated if exits otherwise returns nil!
func (*PhraseCaptchas) NewImage ¶
func (pcs *PhraseCaptchas) NewImage(lang Language, imageformat ImageFormat) (pc *PhraseCaptcha)
NewImage make, store and return new captcha!
Click to show internal directories.
Click to hide internal directories.