|
|
@ -17,8 +17,6 @@ func CheckSign(appID, appKey, random, sign string, ts int, data interface{}) boo |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
v, _ := json.Marshal(data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m := md5.New() |
|
|
|
m := md5.New() |
|
|
|
|
|
|
|
|
|
|
|
sb := strings.Builder{} |
|
|
|
sb := strings.Builder{} |
|
|
@ -26,7 +24,14 @@ func CheckSign(appID, appKey, random, sign string, ts int, data interface{}) boo |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteString(cast.ToString(ts)) |
|
|
|
sb.WriteString(cast.ToString(ts)) |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.Write(v) |
|
|
|
|
|
|
|
|
|
|
|
if val, ok := data.(string); ok { |
|
|
|
|
|
|
|
sb.WriteString(val) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val, _ := json.Marshal(data) |
|
|
|
|
|
|
|
sb.Write(val) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteString(random) |
|
|
|
sb.WriteString(random) |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
@ -44,8 +49,6 @@ func Sign(appID, appKey string, data interface{}) (sign string, random string, t |
|
|
|
|
|
|
|
|
|
|
|
ts = int(time.Now().Unix()) |
|
|
|
ts = int(time.Now().Unix()) |
|
|
|
|
|
|
|
|
|
|
|
v, _ := json.Marshal(data) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m := md5.New() |
|
|
|
m := md5.New() |
|
|
|
|
|
|
|
|
|
|
|
sb := strings.Builder{} |
|
|
|
sb := strings.Builder{} |
|
|
@ -53,7 +56,14 @@ func Sign(appID, appKey string, data interface{}) (sign string, random string, t |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteString(cast.ToString(ts)) |
|
|
|
sb.WriteString(cast.ToString(ts)) |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.Write(v) |
|
|
|
|
|
|
|
|
|
|
|
if val, ok := data.(string); ok { |
|
|
|
|
|
|
|
sb.WriteString(val) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
val, _ := json.Marshal(data) |
|
|
|
|
|
|
|
sb.Write(val) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteString(random) |
|
|
|
sb.WriteString(random) |
|
|
|
sb.WriteByte('-') |
|
|
|
sb.WriteByte('-') |
|
|
|