BaseDao.go 443 B

1234567891011121314151617181920
  1. package dao
  2. import (
  3. "crypto/md5"
  4. "file-manger-server/data"
  5. "fmt"
  6. "strconv"
  7. "strings"
  8. )
  9. // PasswordHashCompute 计算密码的md5值
  10. func PasswordHashCompute(pwd string) string {
  11. var sum = md5.Sum(append(data.PWDHashPrefix, []byte(pwd)...))
  12. var hexBytes string
  13. for b := range sum {
  14. hexBytes = fmt.Sprint(hexBytes, strconv.FormatInt(int64(sum[b]), 16))
  15. }
  16. hexBytes = strings.TrimSpace(hexBytes)
  17. return strings.ToUpper(hexBytes)
  18. }