1
0
mirror of https://github.com/fumiama/tienyik.git synced 2026-06-29 07:20:24 +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

40
http.go Normal file
View File

@@ -0,0 +1,40 @@
package tienyik
import (
"errors"
"net/url"
"github.com/fumiama/tienyik/internal/textio"
)
func (tya *AES) EUrlParams(params url.Values) string {
if tya == nil {
return params.Encode()
}
return url.Values{
textio.FuncName(1, true): {textio.BytesToString(tya.Encrypt(
textio.StringToBytes(params.Encode()),
))},
}.Encode()
}
func (tya *AES) ParseQuery(eparams string) (url.Values, error) {
if tya == nil {
return url.ParseQuery(eparams)
}
q, err := url.ParseQuery(eparams)
if err != nil {
return nil, err
}
if len(q) != 1 {
return nil, errors.New("len(q) must be 1")
}
for _, v := range q {
dec, err := tya.Decrypt(textio.StringToBytes(v[0]))
if err != nil {
return nil, err
}
return url.ParseQuery(textio.BytesToString(dec))
}
panic("unexpected")
}