the following example is my test. The first one cannot be decrypted, and the second can be decrypted. In order to simplify the code, the use of wx.getSetting
is removed. There are actually some
unable to decrypt:
// /app.js
const test = require("./utils/test.js");
App({
onLaunch(){
test.autoLogin()
}
})
// /utils/test.js
module.exports = {
autoLogin(){
wx.getUserInfo({
withCredentials: true,
complete: (res)=>{
// res.encryptedData res.iv
}
})
}
}
can be decrypted:
// /app.js
const test = require("./utils/test.js");
App({
onLaunch(){
test.autoLogin()
},
getUserInfo(fn){
wx.getUserInfo({
withCredentials: true,
complete: fn
})
},
})
// /utils/test.js
const app = getApp()
module.exports = {
autoLogin(fn){
app.getUserInfo((res)=>{
// res.encryptedData res.iv
})
}
}
excuse me, why is this? The back end has no reason and no way to judge which method I used to get the ciphertext. Why are there two situations? The second method feels so bad that it needs to encapsulate a library, and as a result, it has to provide a function externally. Is there any way to make the first method also get the correct ciphertext?