utils.go 348 B

123456789101112131415161718
  1. package utils
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. "regexp"
  6. )
  7. func EmailIsValid(email string) bool {
  8. regexpe := regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`)
  9. return regexpe.MatchString(email)
  10. }
  11. func GetMd5(str string) string {
  12. hasher := md5.New()
  13. hasher.Write([]byte(str))
  14. return hex.EncodeToString(hasher.Sum(nil))
  15. }