2023-03-09 18:15:49 +08:00
|
|
|
|
using Xunit;
|
2022-01-21 16:57:42 +08:00
|
|
|
|
|
|
|
|
|
namespace SKIT.FlurlHttpClient.Wechat.Api.UnitTests
|
|
|
|
|
{
|
2024-02-04 22:52:14 +08:00
|
|
|
|
using SKIT.FlurlHttpClient.Primitives;
|
|
|
|
|
|
2023-03-09 18:15:49 +08:00
|
|
|
|
public class TestCase_ToolsAESUtilityTests
|
2022-01-21 16:57:42 +08:00
|
|
|
|
{
|
|
|
|
|
[Fact(DisplayName = "测试用例:AES-CBC 解密")]
|
|
|
|
|
public void TestAESCBCDecryption()
|
|
|
|
|
{
|
|
|
|
|
string iv = "KEWv/gyiIwAfHvjrLeaX6w==";
|
|
|
|
|
string key = "YZJqKnNFi0KAiKUc0ggC2g==";
|
|
|
|
|
string cipherText = "Gu2PVnxVWl+jK4F8c0liGxfkB5Bj3m5HRvwgEIk1Yb+36RZ3Bg7YmUnud/ooiHz0PQroipsH7GCjlGwUeT04NwmrFaP1y3dRYPLpS43ed9QZWcFIFo+8vTs3Zco6S98DUvaNEAs8duhz/BzfBOZaIHMziRqEtPFI0ZDzCgJluBirJ6Wl3UkygZ5/QLo3KA53qGdip7K48Rq8XbCwuidTCw==";
|
2022-01-21 17:06:31 +08:00
|
|
|
|
|
2022-01-21 16:57:42 +08:00
|
|
|
|
string expectedPlainData = "{\"phoneNumber\":\"186****5613\",\"purePhoneNumber\":\"186****5613\",\"countryCode\":\"86\",\"watermark\":{\"timestamp\":1634545675,\"appid\":\"wxc****17e87e0e0a7\"}}";
|
2024-02-04 22:52:14 +08:00
|
|
|
|
string actualPlainData = Utilities.AESUtility.DecryptWithCBC(encodingKey: new EncodedString(key, EncodingKinds.Base64), encodingIV: new EncodedString(iv, EncodingKinds.Base64), encodingCipher: new EncodedString(cipherText, EncodingKinds.Base64))!;
|
2022-01-21 17:06:31 +08:00
|
|
|
|
|
2022-01-21 16:57:42 +08:00
|
|
|
|
Assert.Equal(expectedPlainData, actualPlainData, ignoreCase: true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|