完善授权凭证授权
This commit is contained in:
@ -2,6 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
"database/sql/driver"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
@ -9,7 +10,9 @@ import (
|
||||
"image/png"
|
||||
"net"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gofrs/uuid"
|
||||
@ -121,10 +124,10 @@ func IsFile(path string) bool {
|
||||
}
|
||||
|
||||
// 去除重复元素
|
||||
func Distinct(list []string) []string {
|
||||
result := make([]string, 0, len(list))
|
||||
func Distinct(a []string) []string {
|
||||
result := make([]string, 0, len(a))
|
||||
temp := map[string]struct{}{}
|
||||
for _, item := range list {
|
||||
for _, item := range a {
|
||||
if _, ok := temp[item]; !ok {
|
||||
temp[item] = struct{}{}
|
||||
result = append(result, item)
|
||||
@ -132,3 +135,11 @@ func Distinct(list []string) []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// 排序+拼接+摘要
|
||||
func Sign(a []string) string {
|
||||
sort.Strings(a)
|
||||
data := []byte(strings.Join(a, ""))
|
||||
has := md5.Sum(data)
|
||||
return fmt.Sprintf("%x", has)
|
||||
}
|
||||
|
Reference in New Issue
Block a user