function.go 1.1 KB

1234567891011121314151617181920212223242526272829
  1. package utils
  2. import "github.com/mojocn/base64Captcha"
  3. //获取验证码
  4. func GetVerifyImg() (idKeyC string, base64stringC string) {
  5. //字符,公式,验证码配置
  6. var configC = base64Captcha.ConfigCharacter{
  7. Height: 60,
  8. Width: 240,
  9. //const CaptchaModeNumber:数字,CaptchaModeAlphabet:字母,CaptchaModeArithmetic:算术,CaptchaModeNumberAlphabet:数字字母混合.
  10. Mode: base64Captcha.CaptchaModeNumberAlphabet,
  11. ComplexOfNoiseText: base64Captcha.CaptchaComplexLower,
  12. ComplexOfNoiseDot: base64Captcha.CaptchaComplexLower,
  13. IsShowHollowLine: false,
  14. IsShowNoiseDot: false,
  15. IsShowNoiseText: false,
  16. IsShowSlimeLine: false,
  17. IsShowSineLine: true,
  18. CaptchaLen: 4,
  19. }
  20. //创建字符公式验证码.
  21. //GenerateCaptcha 第一个参数为空字符串,包会自动在服务器一个随机种子给你产生随机uiid.
  22. var capC base64Captcha.CaptchaInterface
  23. idKeyC, capC = base64Captcha.GenerateCaptcha("8nM77YhE2xOvU6GMQ33A", configC)
  24. //以base64编码
  25. base64stringC = base64Captcha.CaptchaWriteToBase64Encoding(capC)
  26. return idKeyC, base64stringC
  27. }