A:<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber"></button>
B:<button open-type="getUserInfo" lang="zh_CN" bindgetphonenumber="getuserInfo"></button>
注意:
如果你用A请求的方法返回的信息是手机号,用B请求的返回的是用户基本信息 ,open-type决定
方法:
/// <summary>
/// 解密encryptedDataStr
/// </summary>
/// <param name="session_key"></param>
/// <param name="iv"></param>
/// <param name="encryptedDataStr"></param>
/// <returns></returns>
public static string AES_decrypt(string session_key, string iv, string encryptedDataStr)
{
if (session_key == "undefined" || iv == "undefined" || encryptedDataStr == "undefined")
{
return "404";
}
else
{
RijndaelManaged rijalg = new RijndaelManaged();
//-----------------
//设置 cipher 格式 AES-128-CBC
rijalg.KeySize = 128;
rijalg.Padding = PaddingMode.PKCS7;
rijalg.Mode = CipherMode.CBC;
rijalg.Key = Convert.FromBase64String(session_key);
rijalg.IV = Convert.FromBase64String(iv);
byte[] encryptedData = Convert.FromBase64String(encryptedDataStr);
//解密
ICryptoTransform decryptor = rijalg.CreateDecryptor(rijalg.Key, rijalg.IV);
string result;
using (MemoryStream msDecrypt = new MemoryStream(encryptedData))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
result = srDecrypt.ReadToEnd();
}
}
}
return result;
}
}