京东商城订单,商品审核暂停一下
This commit is contained in:
@@ -3,6 +3,8 @@ package jxutils
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/aes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
@@ -882,3 +884,35 @@ func TranslateSoundSize(vendorID, soundPercentage int) (soundSize string) {
|
||||
}
|
||||
return soundSize
|
||||
}
|
||||
|
||||
//ECB,AES模式解密
|
||||
//目前就京东商城订单手机号解密用
|
||||
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)]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user