|
@@ -1,6 +1,9 @@
|
|
|
package lib
|
|
|
|
|
|
import (
|
|
|
+ "crypto/hmac"
|
|
|
+ "crypto/sha256"
|
|
|
+ "encoding/hex"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/server/web/context"
|
|
@@ -497,7 +500,7 @@ func IntListCompare(list1, list2 []int) (isEqual bool, common, onlyList1, onlyLi
|
|
|
onlyList1 = append(onlyList1, a)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
isEqual = true
|
|
@@ -510,4 +513,12 @@ func ChunkBy[T any](list []T, size int) [][]T {
|
|
|
list, chunks = list[size:], append(chunks, list[0:size:size])
|
|
|
}
|
|
|
return append(chunks, list)
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+func GenSignature(apiKey, apiSecret, timestamp string) (signature string) {
|
|
|
+ // 计算签名,签名内容是 "apiKey + timestamp"
|
|
|
+ message := apiKey + timestamp
|
|
|
+ mac := hmac.New(sha256.New, []byte(apiSecret))
|
|
|
+ mac.Write([]byte(message))
|
|
|
+ return hex.EncodeToString(mac.Sum(nil))
|
|
|
+}
|