微信小程序 wx.getUserInfo 解密 C# 代码

花了6小时,弄出来的代码。网上的是PHP代码

 

 public static string DecodeUserInfo(string raw, string signature,string encryptedData, string iv)
        {   
            
            byte[] iv2 = Convert.FromBase64String(iv);

            if (string.IsNullOrEmpty(encryptedData)) return "";
            Byte[] toEncryptArray = Convert.FromBase64String(encryptedData);

            System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged
            {
                Key = Convert.FromBase64String(session_key),
                IV = iv2,
                Mode = System.Security.Cryptography.CipherMode.CBC,
                Padding = System.Security.Cryptography.PaddingMode.PKCS7
            };

            System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateDecryptor();
            Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);

            return Encoding.UTF8.GetString(resultArray);
       
    }

 

微信小程序 wx.getUserInfo 解密 C# 代码

上一篇:微信小程序开发工具测评


下一篇:九宝老师微信小程序开发的过程