Skip to content

Commit

Permalink
Merge pull request #2247 from likui0623/feature_wxapp
Browse files Browse the repository at this point in the history
新增-解密手机号(根据sessionKey解密)
  • Loading branch information
JeffreySu authored Oct 13, 2020
2 parents 0e36e57 + cd14922 commit 90e1ee2
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,26 @@ public static T DecodeEncryptedDataToEntity<T>(string sessionId, string encrypte
var entity = SerializerHelper.GetObject<T>(jsonStr);
return entity;
}
/// <summary>
/// 解密到实例信息
/// </summary>
/// <typeparam name="T">DecodeEntityBase</typeparam>
/// <param name="sessionKey"></param>
/// <param name="encryptedData"></param>
/// <param name="iv"></param>
/// <returns></returns>
public static T DecodeEncryptedDataToEntityEasy<T>(string sessionKey, string encryptedData, string iv)
where T : DecodeEntityBase
{
var jsonStr = DecodeEncryptedData(sessionKey, encryptedData, iv);

//Console.WriteLine("===== jsonStr =====");
//Console.WriteLine(jsonStr);
//Console.WriteLine();

var entity = SerializerHelper.GetObject<T>(jsonStr);
return entity;
}

/// <summary>
/// 解密UserInfo消息(通过SessionId获取)
Expand All @@ -315,6 +335,22 @@ public static DecodedPhoneNumber DecryptPhoneNumber(string sessionId, string enc
{
return DecodeEncryptedDataToEntity<DecodedPhoneNumber>(sessionId, encryptedData, iv);
}
/// <summary>
/// 解密手机号(根据sessionKey解密)
/// </summary>
/// <param name="sessionKey"></param>
/// <param name="encryptedData"></param>
/// <param name="iv"></param>
/// <returns></returns>
public static DecodedPhoneNumber DecryptPhoneNumberBySessionKey(string sessionKey, string encryptedData, string iv)
{
//var resultStr = DecodeEncryptedData(sessionKey, encryptedData, iv);

//var entity = SerializerHelper.GetObject<DecodedPhoneNumber>(resultStr);
//return entity;

return DecodeEncryptedDataToEntityEasy<DecodedPhoneNumber>(sessionKey, encryptedData, iv);
}

/// <summary>
/// 解密微信小程序运动步数
Expand Down

0 comments on commit 90e1ee2

Please sign in to comment.