def decrypt_phone_number():
encrypted_data = request.json['encryptedData']
iv = request.json['iv']
session_key = 'session_key' # 从微信小程序获取的session_key
cipher = AES.new(base64.b64decode(session_key), AES.MODE_CBC, base64.b64decode(iv))
decrypted_data = cipher.decrypt(base64.b64decode(encrypted_data))
print("decrypted_data=", decrypted_data)
print("decrypted_data=",decrypted_data[-1])
#decrypted_data = json.loads(decrypted_data[:-decrypted_data[-1]].decode('utf-8'))
decrypted_data = json.loads(decrypted_data[:-ord(decrypted_data[-1])].decode('utf-8'))
phone_number = decrypted_data.get('phoneNumber')
return jsonify({'phoneNumber': phone_number})
这是chatgpt给的,似乎不太行。
decryptPhoneNumber(e){
console.log("e=",e);
console.log('手机号:', e.detail.errMsg, e.detail.encryptedData, e.detail.iv);
uni.request({
url: API_BASE_URL+'/decryptPhoneNumber',
method: 'POST',
data: {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
},
success: res => {
console.log('解密后的手机号:', res.data.phoneNumber);
},
fail: err => {
console.error('解密失败:', err);
}
});
},
<button type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">获取手机号</button>
有大佬,有好的获取手机号的法子吗?谢谢
--
FROM 120.242.238.*