style: clean code

This commit is contained in:
Fu Diwei
2022-11-18 11:43:45 +08:00
parent 115d374449
commit 5391dbc0b3
3 changed files with 2 additions and 9 deletions

View File

@@ -85,7 +85,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
byte[] plainBytes = Utilities.SM4Utility.DecryptWithGCM(
keyBytes: keyBytes,
nonceBytes: Encoding.UTF8.GetBytes(resource.Nonce),
aadBytes: Encoding.UTF8.GetBytes(resource.AssociatedData),
aadBytes: resource.AssociatedData is null ? null : Encoding.UTF8.GetBytes(resource.AssociatedData),
cipherBytes: Convert.FromBase64String(resource.CipherText)
);
plainJson = Encoding.UTF8.GetString(plainBytes);

View File

@@ -142,11 +142,6 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
public bool Equals(CertificateEntry other)
{
if (ReferenceEquals(null, other))
return false;
if (ReferenceEquals(this, other))
return true;
return string.Equals(AlgorithmType, other.AlgorithmType) &&
string.Equals(Certificate, other.Certificate) &&
string.Equals(SerialNumber, other.SerialNumber);
@@ -156,8 +151,6 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings
{
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (GetType() != obj.GetType())
return false;

View File

@@ -68,7 +68,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Utilities
byte[] plainBytes = DecryptWithGCM(
keyBytes: Encoding.UTF8.GetBytes(key),
nonceBytes: Encoding.UTF8.GetBytes(nonce),
aadBytes: Encoding.UTF8.GetBytes(aad ?? string.Empty),
aadBytes: aad is null ? null : Encoding.UTF8.GetBytes(aad),
cipherBytes: Convert.FromBase64String(cipherText),
paddingMode: paddingMode
);