mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-03-10 00:13:36 +08:00
feat(core): 抽离公共的算法工具类
This commit is contained in:
@@ -56,10 +56,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
plainJson = Utilities.AesUtil.DecryptWithGCM(
|
||||
aesKey: client.MerchantV3Secret,
|
||||
nonce: resource.Nonce,
|
||||
associatedData: resource.AssociatedData,
|
||||
plainJson = Utilities.AESUtility.DecryptWithGCM(
|
||||
key: client.MerchantV3Secret,
|
||||
iv: resource.Nonce,
|
||||
aad: resource.AssociatedData,
|
||||
cipherText: resource.CipherText
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileHash))
|
||||
request.FileHash = Utilities.Sha256Util.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileHash))
|
||||
request.FileHash = Utilities.Sha256Util.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
{
|
||||
@@ -81,7 +81,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".mp4";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileHash))
|
||||
request.FileHash = Utilities.Sha256Util.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
request.FileName = Guid.NewGuid().ToString("N").ToLower() + ".png";
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileHash))
|
||||
request.FileHash = Utilities.Sha256Util.Hash(request.FileBytes).ToLower();
|
||||
request.FileHash = Security.SHA256Utility.Hash(request.FileBytes).ToLower();
|
||||
|
||||
if (string.IsNullOrEmpty(request.FileContentType))
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string package = $"prepay_id={prepayId}";
|
||||
string sign = Utilities.RsaUtil.SignWithSHA256(
|
||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||
privateKey: client.MerchantCertPrivateKey,
|
||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{package}"
|
||||
);
|
||||
@@ -97,7 +97,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
string timestamp = DateTimeOffset.Now.ToLocalTime().ToUnixTimeSeconds().ToString();
|
||||
string nonce = Guid.NewGuid().ToString("N");
|
||||
string sign = Utilities.RsaUtil.SignWithSHA256(
|
||||
string sign = Utilities.RSAUtility.SignWithSHA256(
|
||||
privateKey: client.MerchantCertPrivateKey,
|
||||
plainText: $"{appId}\n{timestamp}\n{nonce}\n{prepayId}"
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNameEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
accountValidationModel.AccountNameEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNameEncryptedData
|
||||
);
|
||||
@@ -53,7 +53,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
accountValidationModel.AccountNumberEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
accountValidationModel.AccountNumberEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
accountValidationModel.AccountNumberEncryptedData!
|
||||
);
|
||||
@@ -100,7 +100,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
downloadBillModel.EncryptKeyEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
downloadBillModel.EncryptKeyEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
downloadBillModel.EncryptKeyEncryptedData
|
||||
);
|
||||
@@ -144,7 +144,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
response.PayerPhoneEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
response.PayerPhoneEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
response.PayerPhoneEncryptedData!
|
||||
);
|
||||
@@ -188,10 +188,10 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
certificateModel.EncryptCertificate.CipherText = Utilities.AesUtil.DecryptWithGCM(
|
||||
aesKey: client.MerchantV3Secret,
|
||||
nonce: certificateModel.EncryptCertificate.Nonce,
|
||||
associatedData: certificateModel.EncryptCertificate.AssociatedData,
|
||||
certificateModel.EncryptCertificate.CipherText = Utilities.AESUtility.DecryptWithGCM(
|
||||
key: client.MerchantV3Secret,
|
||||
iv: certificateModel.EncryptCertificate.Nonce,
|
||||
aad: certificateModel.EncryptCertificate.AssociatedData,
|
||||
cipherText: certificateModel.EncryptCertificate.CipherText
|
||||
);
|
||||
}
|
||||
@@ -242,7 +242,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
complaintModel.PayerPhoneEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
complaintModel.PayerPhoneEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
complaintModel.PayerPhoneEncryptedData!
|
||||
);
|
||||
@@ -290,7 +290,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
guideModel.UserNameEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
guideModel.UserNameEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
guideModel.UserNameEncryptedData
|
||||
);
|
||||
@@ -305,7 +305,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
{
|
||||
try
|
||||
{
|
||||
guideModel.UserMobileEncryptedData = Utilities.RsaUtil.DecryptWithECB(
|
||||
guideModel.UserMobileEncryptedData = Utilities.RSAUtility.DecryptWithECB(
|
||||
client.MerchantCertPrivateKey,
|
||||
guideModel.UserMobileEncryptedData
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
try
|
||||
{
|
||||
return Utilities.RsaUtil.VerifyWithSHA256(
|
||||
return Utilities.RSAUtility.VerifyWithSHA256(
|
||||
publicKey: publicKey,
|
||||
plainText: GetPlainTextForSignature(response),
|
||||
signature: response.WechatpaySignature
|
||||
@@ -58,7 +58,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3
|
||||
|
||||
try
|
||||
{
|
||||
return Utilities.RsaUtil.VerifyWithSHA256ByCertificate(
|
||||
return Utilities.RSAUtility.VerifyWithSHA256ByCertificate(
|
||||
certificate: certificate,
|
||||
plainText: GetPlainTextForSignature(response),
|
||||
signature: response.WechatpaySignature
|
||||
|
||||
Reference in New Issue
Block a user