微信支付退款结果通知API地址:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_16&index=10
static void Main(string[] args)
{
string reqInfo = "加密字符串";
string result= DecodeReqInfo(reqInfo);//解密后的结果
}
public static string DecodeAES256ECB(string s, string key)
{
string r = null;
try
{
byte[] keyArray = UTF8Encoding.UTF8.GetBytes(key);
byte[] toEncryptArray = Convert.FromBase64String(s);
RijndaelManaged rDel = new RijndaelManaged();
rDel.Key = keyArray;
rDel.Mode = CipherMode.ECB;
rDel.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = rDel.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
r = UTF8Encoding.UTF8.GetString(resultArray);
}
catch { }
return r;
}
public static string DecodeReqInfo(string s)//s需要解密的字符串
{
string r = null;
string key = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(_key, "md5").ToLower();//秘钥
r = DecodeAES256ECB(s, key);
return r;
}
参考:http://www.w3dev.cn/article/20171011/cshart-decode-weixin-pay-req-info.aspx