You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
735 B
33 lines
735 B
|
1 year ago
|
package tada
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"reflect"
|
||
|
|
"server/config"
|
||
|
|
"server/util"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
func GetKeyG() string {
|
||
|
|
key := TestKey
|
||
|
|
if config.GetBase().Release {
|
||
|
|
key = AgentKey
|
||
|
|
}
|
||
|
|
return util.CalculateMD5(time.Now().UTC().Add(-4*time.Hour).Format("06012") + AgentID + key)
|
||
|
|
}
|
||
|
|
|
||
|
|
func GetSignKey(req interface{}) string {
|
||
|
|
keyG := GetKeyG()
|
||
|
|
str := ""
|
||
|
|
ref := reflect.ValueOf(req)
|
||
|
|
reft := reflect.TypeOf(req)
|
||
|
|
if reft.Kind() == reflect.Ptr {
|
||
|
|
ref = ref.Elem()
|
||
|
|
reft = reft.Elem()
|
||
|
|
}
|
||
|
|
for i := 0; i < ref.NumField(); i++ {
|
||
|
|
str += fmt.Sprintf("%s=%v&", reft.Field(i).Name, ref.Field(i).Interface())
|
||
|
|
}
|
||
|
|
return util.GenerateRandomString(6) + util.CalculateMD5(fmt.Sprintf("%sAgentId=%s", str, AgentID)+keyG) + util.GenerateRandomString(6)
|
||
|
|
}
|