30 lines
687 B
Go
30 lines
687 B
Go
package robot
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/utils"
|
|
"time"
|
|
|
|
jsoniter "github.com/json-iterator/go"
|
|
"github.com/nacos-group/nacos-sdk-go/util"
|
|
)
|
|
|
|
type LoginParam struct {
|
|
Account string `json:"account"`
|
|
ServerId string `json:"serverId"`
|
|
TimeStamp int64 `json:"timestamp"`
|
|
}
|
|
|
|
func (r *Robot) BuildSecStr() string {
|
|
jsonByte, _ := jsoniter.Marshal(&LoginParam{
|
|
Account: r.account,
|
|
ServerId: r.sid,
|
|
TimeStamp: time.Now().Unix(),
|
|
})
|
|
jsonBase64 := utils.Base64Encode(jsonByte)
|
|
// log.Printf("client base64:%s", jsonBase64)
|
|
clientMd5key := util.Md5(jsonBase64)
|
|
// log.Printf("client md5:%s", clientMd5key)
|
|
return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64)
|
|
}
|