encode.go 336 B

123456789101112131415161718
  1. package password
  2. import (
  3. "crypto/md5"
  4. "encoding/hex"
  5. )
  6. // Encode 对密码两次md5加盐
  7. func Encode(password string) string {
  8. encodePwd := md5Encode(md5Encode(password+"pmail") + "pmail2023")
  9. return encodePwd
  10. }
  11. func md5Encode(str string) string {
  12. h := md5.New()
  13. h.Write([]byte(str))
  14. return hex.EncodeToString(h.Sum(nil))
  15. }