解密完成
This commit is contained in:
@@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("广东广州市白云区棠景街道水边街棠下村东一街36号(可放北街的菜鸟驿站)", "广州")
|
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("浙江杭州市萧山区萧山经济技术开发区建设四路龙湖天玺 16幢1单元3303室", "")
|
||||||
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ func TestBatchWalkingDistance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAA(t *testing.T) {
|
func TestAA(t *testing.T) {
|
||||||
result, err := autonaviAPI.GetCoordinateAreaInfo(113.325814, 23.133907)
|
result, err := autonaviAPI.GetCoordinateAreaInfo(120.287109, 30.205960)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package jdshopapi
|
package jdshopapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ type CallBackResult struct {
|
|||||||
GetOrderResult
|
GetOrderResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err error) {
|
func (a *API) GetCallbackMsg(request *http.Request) (call *GetOrderResult, err error) {
|
||||||
data, err := ioutil.ReadAll(request.Body)
|
data, err := ioutil.ReadAll(request.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -22,7 +21,6 @@ func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mapData := utils.URLValues2Map(values)
|
mapData := utils.URLValues2Map(values)
|
||||||
fmt.Println(mapData)
|
|
||||||
utils.Map2StructByJson(mapData, &call, false)
|
utils.Map2StructByJson(mapData, &call, false)
|
||||||
return call, err
|
return call, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,16 @@
|
|||||||
package jdshopapi
|
package jdshopapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
"crypto/cipher"
|
"crypto/cipher"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"reflect"
|
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"golang.org/x/text/encoding/simplifiedchinese"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateShopCategory(t *testing.T) {
|
func TestCreateShopCategory(t *testing.T) {
|
||||||
@@ -109,35 +106,25 @@ func TestTryGetCookie(t *testing.T) {
|
|||||||
func TestAAADS(t *testing.T) {
|
func TestAAADS(t *testing.T) {
|
||||||
str := "AASWvkdk5a60bjm3lFqaoCyzJprhJZvabCAbNtGu14Lu/ZBGNYf/MdPCEIcIN9oVbEw="
|
str := "AASWvkdk5a60bjm3lFqaoCyzJprhJZvabCAbNtGu14Lu/ZBGNYf/MdPCEIcIN9oVbEw="
|
||||||
data, _ := base64.StdEncoding.DecodeString(str)
|
data, _ := base64.StdEncoding.DecodeString(str)
|
||||||
dataStr := hex.EncodeToString(data)
|
// fmt.Println("all:", dataStr) //96be4764e5aeb46e39b7945a9aa02cb3
|
||||||
fmt.Println("all:", dataStr) //96be4764e5aeb46e39b7945a9aa02cb3
|
// fmt.Println("key ID:", dataStr[4:36])
|
||||||
fmt.Println("key ID:", dataStr[4:36])
|
// fmt.Println("IV:", dataStr[36:68])
|
||||||
fmt.Println("IV:", dataStr[36:68])
|
// fmt.Println("key main", dataStr[68:])
|
||||||
fmt.Println("key main", dataStr[68:])
|
|
||||||
data2, _ := base64.StdEncoding.DecodeString("XsGNdyDyDHnR79iKU6d5LTSJYaQyWAEssDoD7VM5Kks=")
|
data2, _ := base64.StdEncoding.DecodeString("XsGNdyDyDHnR79iKU6d5LTSJYaQyWAEssDoD7VM5Kks=")
|
||||||
// str2 := []byte(dataStr[68:])
|
b := bytes.NewBuffer(data)
|
||||||
// key := []byte(dataStr2)
|
b.Next(18)
|
||||||
iv, _ := hex.DecodeString("269ae1259bda6c201b36d1aed782eefd")
|
iv := make([]byte, 16)
|
||||||
main, _ := hex.DecodeString("90463587ff31d3c210870837da156c4c")
|
b.Read(iv)
|
||||||
fmt.Println(iv)
|
main := make([]byte, len(data)-18-16)
|
||||||
fmt.Println(data[18:34])
|
b.Read(main)
|
||||||
decryptedData, err := Decrypt(main, data2, iv)
|
// fmt.Println(data)
|
||||||
|
// fmt.Println(main)
|
||||||
|
// fmt.Println(iv)
|
||||||
|
decryptedData, err := Decrypt(main, data2[:16], iv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
data3, _ := simplifiedchinese.GBK.NewDecoder().Bytes(decryptedData) //gbk 转 utf-8
|
fmt.Println("data", string(decryptedData))
|
||||||
fmt.Println("data", string(data3))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSZXCXZ(t *testing.T) {
|
|
||||||
//53cb68569fb790a8e17ae3b0c735991f
|
|
||||||
// fmt.Println(len(data))
|
|
||||||
}
|
|
||||||
|
|
||||||
func StringToBytes(s string) []byte {
|
|
||||||
sh := (*reflect.StringHeader)(unsafe.Pointer(&s))
|
|
||||||
bh := reflect.SliceHeader{sh.Data, sh.Len, 0}
|
|
||||||
return *(*[]byte)(unsafe.Pointer(&bh))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
|
func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
|
||||||
@@ -145,43 +132,13 @@ func Decrypt(decryptBytes, key, iv []byte) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
fmt.Println(block.BlockSize())
|
|
||||||
blockMode := cipher.NewCBCDecrypter(block, iv)
|
blockMode := cipher.NewCBCDecrypter(block, iv)
|
||||||
decrypted := make([]byte, len(decryptBytes))
|
blockMode.CryptBlocks(decryptBytes, decryptBytes)
|
||||||
blockMode.CryptBlocks(decrypted, decryptBytes)
|
return PKCS5UnPadding(decryptBytes), nil
|
||||||
fmt.Println(decrypted)
|
|
||||||
decrypted = PKCS5UnPadding(decrypted)
|
|
||||||
return decrypted, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func PKCS5UnPadding(decrypted []byte) []byte {
|
func PKCS5UnPadding(decrypted []byte) []byte {
|
||||||
length := len(decrypted)
|
length := len(decrypted)
|
||||||
fmt.Println(length)
|
|
||||||
unPadding := int(decrypted[length-1])
|
unPadding := int(decrypted[length-1])
|
||||||
fmt.Println(unPadding)
|
|
||||||
return decrypted[:(length - unPadding)]
|
return decrypted[:(length - unPadding)]
|
||||||
}
|
}
|
||||||
|
|
||||||
func CBCDecript(src, key, iv []byte) (dst []byte, err error) {
|
|
||||||
var (
|
|
||||||
block cipher.Block
|
|
||||||
blockMode cipher.BlockMode
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(iv) != aes.BlockSize {
|
|
||||||
return nil, fmt.Errorf("iv")
|
|
||||||
}
|
|
||||||
if len(key) != 32 {
|
|
||||||
return nil, fmt.Errorf("key")
|
|
||||||
}
|
|
||||||
|
|
||||||
if block, err = aes.NewCipher(key); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
blockMode = cipher.NewCBCDecrypter(block, iv)
|
|
||||||
dst = make([]byte, len(src))
|
|
||||||
blockMode.CryptBlocks(dst, src)
|
|
||||||
dst = PKCS5UnPadding(dst)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user