京东商品

This commit is contained in:
苏尹岚
2020-06-09 18:58:04 +08:00
parent 762a41dbdd
commit 73b0253721
5 changed files with 321 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
package jdshopapi
import (
"crypto/aes"
"encoding/base64"
"fmt"
"io/ioutil"
"net/http"
@@ -91,7 +93,45 @@ func TestUpdateWaybill(t *testing.T) {
// t.Log(utils.Format4Output(result, false))
}
func TestAAAAAA(t *testing.T) {
str := "2020-06-02 16:00-17:00"
fmt.Println(str[:strings.LastIndex(str, "-")])
func TestTryGetCookie(t *testing.T) {
result, err := api.TryGetCookie()
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestAAADS(t *testing.T) {
var s float64 = 200
fmt.Println(strings.TrimRight(fmt.Sprintf("%.2f", s), "0."))
}
func DecryptDESECB(d, key []byte) string {
data, err := base64.StdEncoding.DecodeString(string(d))
if err != nil {
return ""
}
block, err := aes.NewCipher(key)
if err != nil {
return ""
}
bs := block.BlockSize()
if len(data)%bs != 0 {
return ""
}
out := make([]byte, len(data))
dst := out
for len(data) > 0 {
block.Decrypt(dst, data[:bs])
data = data[bs:]
dst = dst[bs:]
}
out = PKCS5UnPadding(out)
return string(out)
}
func PKCS5UnPadding(origData []byte) []byte {
length := len(origData)
unpadding := int(origData[length-1])
return origData[:(length - unpadding)]
}