Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WxOpen v3.15.10-beta1 EncryptHelper.DecodeEncryptedData() 方法添加 keySiz… #2741

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ and limitations under the License.
修改标识:likui0623 - 20201013
修改描述:添加解密到实例信息方法

修改标识:Senparc - 20221129
修改描述:v3.15.10 EncryptHelper.DecodeEncryptedData() 方法添加 keySize 参数

----------------------------------------------------------------*/

using System;
Expand Down Expand Up @@ -123,14 +126,14 @@ public static bool CheckSignature(string sessionId, string rawData, string compa

#region 私有方法

private static byte[] AES_Decrypt(String Input, byte[] Iv, byte[] Key)
private static byte[] AES_Decrypt(String Input, byte[] Iv, byte[] Key, int keySize = 128)
{
#if NET462
RijndaelManaged aes = new RijndaelManaged();
#else
SymmetricAlgorithm aes = Aes.Create();
#endif
aes.KeySize = 128;//原始:256
aes.KeySize = keySize;//原始:256
aes.BlockSize = 128;
aes.Mode = CipherMode.CBC;
aes.Padding = PaddingMode.PKCS7;
Expand Down Expand Up @@ -219,14 +222,15 @@ private static byte[] decode2(byte[] decrypted)
/// <param name="sessionKey">储存在 SessionBag 中的当前用户 会话 SessionKey</param>
/// <param name="encryptedData">接口返回数据中的 encryptedData 参数</param>
/// <param name="iv">接口返回数据中的 iv 参数,对称解密算法初始向量</param>
/// <param name="keySize">默认 128,</param>
/// <returns></returns>
public static string DecodeEncryptedData(string sessionKey, string encryptedData, string iv)
public static string DecodeEncryptedData(string sessionKey, string encryptedData, string iv, int keySize = 128)
{
//var aesCipher = Convert.FromBase64String(encryptedData);
var aesKey = Convert.FromBase64String(sessionKey);
var aesIV = Convert.FromBase64String(iv);

var result = AES_Decrypt(encryptedData, aesIV, aesKey);
var result = AES_Decrypt(encryptedData, aesIV, aesKey, keySize);
var resultStr = Encoding.UTF8.GetString(result);
return resultStr;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>3.15.9</Version>
<Version>3.15.10-beta1</Version>
<LangVersion>9.0</LangVersion>
<AssemblyName>Senparc.Weixin.WxOpen</AssemblyName>
<RootNamespace>Senparc.Weixin.WxOpen</RootNamespace>
Expand Down Expand Up @@ -151,25 +151,26 @@
v3.8.512 添加解密到实例信息方法
v3.10.101 新增 WxOpen 专属 AccessTokenContainer,解决没有提供 name 参数的情况下,Register 过程和公众号注册信息发生冲突的问题
v3.10.102 修正 UniformSendData.Mp_Template_Msg.Miniprogram 参数 pagepath -&gt; page
v3.10.103 修正 WxOpenApiHandlerWapper 正确引用 AccessTokenContainer
v3.10.104 添加 WxAppApi.GenerateScheme() 接口
v3.10.401 升级 MessageApi.SendSubscribe() 方法参数
v3.11.100 修改完善“附近的小程序”接口
v3.13.500-preview4.1 添加“Short Link”接口
v3.14 添加 ExpressApi 接口
v3.14.2 添加“小程序违规和申诉管理”消息事件
v3.14.3 添加 UrlLinkApi.Generate() 接口
v3.14.4 添加 BusinessApi.GetUserPhoneNumber() 接口
v3.14.5 修改“下发小程序和公众号统一的服务消息”接口参数,提升兼容性
v3.14.10.1 修复 WxAppApi.GetWxaCodeUnlimitAsync() 接口参数错误
v3.15.2 添加小程序隐私接口
v3.15.3 添加商户客户参数(BusinessId)
v3.15.4 添加小程序客服管理接口
v3.15.6 添加“异步校验图片/音频是否含有违法违规内容”接口
v3.15.7
1、添加 OnEvent_MediaCheckRequest() 方法:内容安全回调 - wxa_media_check 推送结果
2、修复 RequestMsgType.Event 返回值没有正确赋值的问题
</PackageReleaseNotes>
v3.10.103 修正 WxOpenApiHandlerWapper 正确引用 AccessTokenContainer
v3.10.104 添加 WxAppApi.GenerateScheme() 接口
v3.10.401 升级 MessageApi.SendSubscribe() 方法参数
v3.11.100 修改完善“附近的小程序”接口
v3.13.500-preview4.1 添加“Short Link”接口
v3.14 添加 ExpressApi 接口
v3.14.2 添加“小程序违规和申诉管理”消息事件
v3.14.3 添加 UrlLinkApi.Generate() 接口
v3.14.4 添加 BusinessApi.GetUserPhoneNumber() 接口
v3.14.5 修改“下发小程序和公众号统一的服务消息”接口参数,提升兼容性
v3.14.10.1 修复 WxAppApi.GetWxaCodeUnlimitAsync() 接口参数错误
v3.15.2 添加小程序隐私接口
v3.15.3 添加商户客户参数(BusinessId)
v3.15.4 添加小程序客服管理接口
v3.15.6 添加“异步校验图片/音频是否含有违法违规内容”接口
v3.15.7
1、添加 OnEvent_MediaCheckRequest() 方法:内容安全回调 - wxa_media_check 推送结果
2、修复 RequestMsgType.Event 返回值没有正确赋值的问题
v3.15.10 EncryptHelper.DecodeEncryptedData() 方法添加 keySize 参数
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down