Closed cielu closed 5 years ago
@silenceper 老兄,这个问题修复不?加个手机号解密的,目前小程序只能解密用户的信息
// 用户手机号
type PhoneInfo struct {
PhoneNumber string `json:"phoneNumber"`
PurePhoneNumber string `json:"purePhoneNumber"`
CountryCode string `json:"countryCode"`
Watermark struct {
Timestamp int64 `json:"timestamp"`
AppID string `json:"appid"`
} `json:"watermark"`
}
mode := cipher.NewCBCDecrypter(block, ivBytes)
mode.CryptBlocks(cipherText, cipherText)
cipherText, err = pkcs7Unpad(cipherText, block.BlockSize())
if err != nil {
return nil, err
}
var phoneInfo PhoneInfo
err = json.Unmarshal(cipherText, &phoneInfo)
if err != nil {
return nil, err
}
if phoneInfo.Watermark.AppID != AppId {
return nil, errors.New("app id 不匹配")
}
fixed #167
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html