1
0
mirror of https://github.com/fumiama/tienyik.git synced 2026-06-29 23:40:28 +08:00

feat: add more apis

This commit is contained in:
源文雨
2025-10-31 23:20:46 +08:00
parent 15fcc9a338
commit da1de770ad
19 changed files with 509 additions and 82 deletions

View File

@@ -2,12 +2,18 @@ package hson
import (
"bytes"
"encoding/base64"
"encoding/json"
"github.com/fumiama/tienyik"
"github.com/fumiama/tienyik/internal/log"
"github.com/fumiama/tienyik/internal/op"
)
type reqbody struct {
EData string `json:"edata"`
}
func Marshal(tya *tienyik.AES, v any) []byte {
w := bytes.NewBuffer(make([]byte, 0, 1024))
err := json.NewEncoder(w).Encode(v)
@@ -16,7 +22,9 @@ func Marshal(tya *tienyik.AES, v any) []byte {
}
log.Debugln("Marshal JSON:", w.String())
if tya != nil {
return tya.Encrypt(w.Bytes())
return tya.Encrypt(op.Must(json.Marshal(&reqbody{
EData: base64.StdEncoding.EncodeToString(w.Bytes()),
})))
}
return w.Bytes()
}