在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
获取OpenId和SessionKey private string GetOpenIdAndSessionKeyString(string code) { string wxUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + CommonData.WxAppId + "&secret=" + CommonData.WxAppSecret + "&js_code=" + code + "&grant_type=authorization_code"; return GetResponse(wxUrl); } code public static string AESDecrypt(string text) { try { //判断是否是16位 如果不够补0 //text = tests(text); //16进制数据转换成byte byte[] encryptedData =Convert.FromBase64String(text); // strToToHexByte(text); RijndaelManaged rijndaelCipher = new RijndaelManaged(); rijndaelCipher.Key =Convert.FromBase64String(AesKey); // Encoding.UTF8.GetBytes(AesKey); rijndaelCipher.IV = Convert.FromBase64String(AesIV);// Encoding.UTF8.GetBytes(AesIV); rijndaelCipher.Mode = CipherMode.CBC; rijndaelCipher.Padding = PaddingMode.PKCS7; ICryptoTransform transform = rijndaelCipher.CreateDecryptor(); byte[] plainText = transform.TransformFinalBlock(encryptedData, 0, encryptedData.Length); string result = Encoding.UTF8.GetString(plainText);//UTF8防止乱码 //int index = result.LastIndexOf('>'); //result = result.Remove(index + 1); return result; } catch (Exception ex) { return null; } }
|
请发表评论