小程序
小游戏
企业微信
微信支付
扫描小程序码分享
从官方文档中,下载到了手机号解密的demo,只有C++,Node,Php,Python的代码,我需要.net的示例代码,请提供一下
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
/// <summary>
/// 微信小程序解密用户数据
/// </summary>
/// <param name="AesIV">iv</param>
/// <param name="AesKey">session_key</param>
/// <param name="inputdata">encryptedData</param>
public
static
JObject decodeUser(
string
AesIV,
AesKey,
inputdata)
{
JObject jo =
new
JObject();
try
AesIV = AesIV.Replace(
" "
,
"+"
);
AesKey = AesKey.Replace(
inputdata = inputdata.Replace(
byte
[] encryptedData = Convert.FromBase64String(inputdata);
RijndaelManaged rijndaelCipher =
RijndaelManaged();
rijndaelCipher.Key = Convert.FromBase64String(AesKey);
// Encoding.UTF8.GetBytes(AesKey);
rijndaelCipher.IV = Convert.FromBase64String(AesIV);
// Encoding.UTF8.GetBytes(AesIV);
rijndaelCipher.Mode = CipherMode.CBC;
rijndaelCipher.Padding = PaddingMode.PKCS7;
ICryptoTransform transform = rijndaelCipher.CreateDecryptor();
[] plainText = transform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
result = Encoding.UTF8.GetString(plainText);
jo = JsonConvert.DeserializeObject<JObject>(result);
jo[
"code"
] =
"200"
;
}
catch
(Exception e)
"500"
"msg"
] = e.Message;
return
jo;
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
/// <summary>
/// 微信小程序解密用户数据
/// </summary>
/// <param name="AesIV">iv</param>
/// <param name="AesKey">session_key</param>
/// <param name="inputdata">encryptedData</param>
public
static
JObject decodeUser(
string
AesIV,
string
AesKey,
string
inputdata)
{
JObject jo =
new
JObject();
try
{
AesIV = AesIV.Replace(
" "
,
"+"
);
AesKey = AesKey.Replace(
" "
,
"+"
);
inputdata = inputdata.Replace(
" "
,
"+"
);
byte
[] encryptedData = Convert.FromBase64String(inputdata);
RijndaelManaged rijndaelCipher =
new
RijndaelManaged();
rijndaelCipher.Key = Convert.FromBase64String(AesKey);
// Encoding.UTF8.GetBytes(AesKey);
rijndaelCipher.IV = Convert.FromBase64String(AesIV);
// Encoding.UTF8.GetBytes(AesIV);
rijndaelCipher.Mode = CipherMode.CBC;
rijndaelCipher.Padding = PaddingMode.PKCS7;
ICryptoTransform transform = rijndaelCipher.CreateDecryptor();
byte
[] plainText = transform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
string
result = Encoding.UTF8.GetString(plainText);
jo = JsonConvert.DeserializeObject<JObject>(result);
jo[
"code"
] =
"200"
;
}
catch
(Exception e)
{
jo[
"code"
] =
"500"
;
jo[
"msg"
] = e.Message;
}
return
jo;
}