package lib import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "fmt" "time" ) const ColdVerify_OpenApi_Key = "coldverify" const ColdVerify_OpenApi_Secret = "H3L9OPQR2VX8ZZYN7STKFG5JMWB1CV4D" func GenColdVerifySignature() (signature, timestamp string) { // 计算签名,签名内容是 "apiKey + timestamp" timestamp = fmt.Sprintf("%d", time.Now().Unix()) message := ColdVerify_OpenApi_Key + timestamp mac := hmac.New(sha256.New, []byte(ColdVerify_OpenApi_Secret)) mac.Write([]byte(message)) return hex.EncodeToString(mac.Sum(nil)), timestamp }