package dao import ( "crypto/md5" "file-manger-server/data" "fmt" "strconv" "strings" ) // PasswordHashCompute 计算密码的md5值 func PasswordHashCompute(pwd string) string { var sum = md5.Sum(append(data.PWDHashPrefix, []byte(pwd)...)) var hexBytes string for b := range sum { hexBytes = fmt.Sprint(hexBytes, strconv.FormatInt(int64(sum[b]), 16)) } hexBytes = strings.TrimSpace(hexBytes) return strings.ToUpper(hexBytes) }