package common

import (
	"fmt"
	"go_dreamfactory/cmd/v2/model"
	"go_dreamfactory/utils"
	"time"

	jsoniter "github.com/json-iterator/go"
	"github.com/nacos-group/nacos-sdk-go/util"
)

func BuildSecStr(sid, account string) string {
	now := time.Now().Unix()
	jsonByte, _ := jsoniter.Marshal(&model.LoginParam{
		Account:   account,
		ServerId:  sid,
		TimeStamp: now,
	})
	jsonBase64 := utils.Base64Encode(jsonByte)
	// log.Printf("client base64:%s", jsonBase64)
	clientMd5key := util.Md5(jsonBase64)
	// logrus.Debugf("client md5:%s", clientMd5key)
	return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64)
}
