util.go 313 B

12345678910111213141516171819
  1. package captcha
  2. import (
  3. "math/rand"
  4. "regexp"
  5. "time"
  6. )
  7. var phoneReg = regexp.MustCompile("^[1][3-9][0-9]{9}$")
  8. func RandomNumberGenerator() *rand.Rand {
  9. s1 := rand.NewSource(time.Now().UnixNano())
  10. r1 := rand.New(s1)
  11. return r1
  12. }
  13. func PhoneCheck(phone string) bool {
  14. return phoneReg.MatchString(phone)
  15. }