Skip to content

Commit

Permalink
feat: appinfo 增加序列化和反序列化
Browse files Browse the repository at this point in the history
  • Loading branch information
Redmomn committed Dec 25, 2024
1 parent 0c9336b commit c5bcded
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions client/auth/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package auth

import (
"encoding/hex"
"encoding/json"
"strings"

"github.com/LagrangeDev/LagrangeGo/internal/proto"
Expand Down Expand Up @@ -219,8 +220,8 @@ type AppInfo struct {
SubSigmap int `json:"sub_sigmap"`
NTLoginType int `json:"nt_login_type"`

SignExtraHexLower string `json:"sign_extra_hex_lower"`
SignExtraHexUpper string `json:"sign_extra_hex_upper"`
SignExtraHexLower string `json:"-"`
SignExtraHexUpper string `json:"-"`
}

func init() {
Expand All @@ -231,3 +232,18 @@ func init() {
}
}
}

func (app *AppInfo) Marshal() ([]byte, error) {
return json.Marshal(app)
}

func UnmarshalAppInfo(data []byte) (*AppInfo, error) {
app := &AppInfo{}
err := json.Unmarshal(data, app)
if err != nil {
return nil, err
}
app.SignExtraHexLower = hex.EncodeToString(proto.DynamicMessage{2: app.PackageSign}.Encode())
app.SignExtraHexUpper = strings.ToUpper(app.SignExtraHexLower)
return app, nil
}

0 comments on commit c5bcded

Please sign in to comment.