Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Captcha ¶
func NewBannerCaptcha ¶
func NewBannerCaptcha() Captcha
Example ¶
package main import ( "fmt" "math/rand" "moul.io/captcha/captcha" ) func main() { rand.Seed(42) captcha := captcha.NewBannerCaptcha() question, _ := captcha.Question() fmt.Println(question) valid, _ := captcha.Validate("lorem") fmt.Println(valid) valid, _ = captcha.Validate("ipsum") fmt.Println(valid) valid, _ = captcha.Validate("HRUKP") fmt.Println(valid) valid, _ = captcha.Validate("hrukp") fmt.Println(valid) valid, _ = captcha.Validate("\n hRuKP\t \n\n \t") fmt.Println(valid) valid, _ = captcha.Validate("dolor") fmt.Println(valid) }
Output: _ _ | |_ _ _ _ _ | |__ _ __ | ' \ | '_|| || || / /| '_ \ |_||_||_| \_,_||_\_\| .__/ |_| false false true true true false
func NewMathCaptcha ¶
func NewMathCaptcha() Captcha
Example ¶
package main import ( "fmt" "math/rand" "moul.io/captcha/captcha" ) func main() { rand.Seed(42) captcha := captcha.NewMathCaptcha() question, _ := captcha.Question() fmt.Println(question) valid, _ := captcha.Validate("42") fmt.Println(valid) valid, _ = captcha.Validate("lorem ipsum") fmt.Println(valid) valid, _ = captcha.Validate("1 + 3") fmt.Println(valid) valid, _ = captcha.Validate("4") fmt.Println(valid) valid, _ = captcha.Validate("\n 4\t \n\n \t") fmt.Println(valid) }
Output: 1 + 3 false false false true true
func NewRandomCaptcha ¶
func NewRandomCaptcha() Captcha
Example ¶
package main import ( "fmt" "math/rand" "moul.io/captcha/captcha" ) func main() { rand.Seed(42) // first captcha c := captcha.NewRandomCaptcha() question, _ := c.Question() fmt.Println(question) // second captcha c = captcha.NewRandomCaptcha() question, _ = c.Question() fmt.Println(question) }
Output: 3 + 4 _ _ _ __ | |_ | |_ _ _ ___ | '_ \| _|| _|| || |/ -_) | .__/ \__| \__| \_,_|\___| |_|
Click to show internal directories.
Click to hide internal directories.