Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

31 řádky
940 B

  1. package common
  2. import (
  3. "github.com/mojocn/base64Captcha"
  4. )
  5. var captchaStore = base64Captcha.DefaultMemStore
  6. var captchaDriver = base64Captcha.NewDriverString(
  7. 40, // height
  8. 120, // width
  9. 0, // noise count (auto)
  10. base64Captcha.OptionShowSlimeLine, // show slime lines
  11. 5, // code length
  12. base64Captcha.TxtSimpleCharaters, // digits+letters excluding confusing chars
  13. nil, // bg color (auto)
  14. nil, // font storage (auto)
  15. []string{"wqy-microhei.ttc"}, // font files
  16. )
  17. var captchaInstance = base64Captcha.NewCaptcha(captchaDriver, captchaStore)
  18. func GenerateCaptcha() (string, string, error) {
  19. id, b64s, _, err := captchaInstance.Generate()
  20. return id, b64s, err
  21. }
  22. func VerifyCaptcha(id, code string) bool {
  23. return captchaStore.Verify(id, code, true)
  24. }