예제 #1
0
        static void Test()
        {
            string did, privateKey;
            var    result = CertificateUtil.GetPfxPrivateKeyAndDidValue(@"C:\Users\Administrator\Desktop\pfx\weibo\api.jk.cn(2).pfx",
                                                                        out privateKey, out did);

            if (result)
            {
                ParaCollection pc = new ParaCollection();
                pc.Add("_did", did);
                pc.Add("_dtk", "Ly/4WjYKFOqZuYtY739SvsOkR73FUuy6heTKB3lm/T6xYBYhnXcRBvkvZ/WEQFEX2yN3F4+x3uvsDuSs/nnij+SSeH2JLTMYhMnLaa8Crc4kGWvZHbuRSK/whrQ2ceCRdKSGVm3PfamQQ9MPBh/r4AvM9wt5Paduw+FxxT+6mH60vlSU7utJV4xDuuBByvAi/cYU6hAqwxYTDMv3tOS3V6qm0LhlRxJHExMGrPgzCIqctsspemin04iurHDOkG30x+VN0CkuWdcpk7PsBQVIQA==", true);
                pc.Add("_mt", "user.weiboLogin");
                pc.Add("_chl", "MZSD");
                pc.Add("accessToken", "2.00vpN7TBvqH7EDbd3ddc819a7Xdi2C");
                pc.Add("_sm", "rsa");
                pc.Add("_aid", "1");
                pc.Add("_vc", "30803");
                pc.Add("_ft", "json");

                //pc.Add("_did", did);
                //pc.Add("_mt", "user.getWebUserToken");
                //pc.Add("_uid", "12651160806");
                //pc.Add("_chl", "MZSD");
                //pc.Add("_sm", "rsa");
                //pc.Add("_tk", "KUUKALUWp9fVZCwkLXeJ4SIU1coPRWzcMjqoOj5+/I/SVJn8iplPyatsGiqmfw2kY0J5E/HFPKy6KFQ6zZ3BX8PogJsuLWZHH4J1g7gK4sI6EY6Dur2+fZKAfJqwsmuaZGrfO7tuzmE+JrWo27dbaLUnIQgG77ALu3UvgSSt2mqfHfQCFXnNaKglAuiBUETWptWunj4aasJ4G9ctwC+74Bd4n1d5jxHxjtxXdRUAZDFoawxDfeM8oZZPj4aH9OMwa8Hn2nX2g2O8DvGuDytat11mF6zqzJL52tggonHHRrXX6YxgO9188gNZQUwLXbkoDjKSJ7LlO9XrQ6iPlwiKH90HKvgKzQWhReweynjc73i4rnqVx7gUGV9xfpyXxYi6");
                //pc.Add("_aid", "1");
                //pc.Add("_vc", "30803");
                //pc.Add("_ft", "json");

                var sig = PapdHelper.CalcSig(pc.ToString(), null, privateKey);

                Console.WriteLine(sig);
            }
        }
예제 #2
0
        private void btnCalc_Click(object sender, EventArgs e)
        {
            string combineStr = string.Empty;

            try
            {
                if (this.textBox2.Text.Trim().Length < 1)
                {
                    MsgBox.ShowInfo("请输入参数!");
                    return;
                }
                string[]      content = this.textBox2.Lines;
                StringBuilder builder = new StringBuilder();
                foreach (var line in content)
                {
                    string[] parts = line.Split(" \t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (parts.Length < 1)
                    {
                        continue;
                    }
                    if (parts[0] == "_sig")
                    {
                        continue;
                    }
                    if (parts.Length == 2)
                    {
                        builder.Append(parts[0] + "=" + System.Web.HttpUtility.UrlEncode(parts[1]));
                    }
                    else if (parts.Length == 1)
                    {
                        builder.Append(parts[0] + "=");
                    }
                    builder.Append("&");
                }
                string postData = builder.ToString();
                postData = postData.Substring(0, postData.Length - 1);

                this.textBox3.Text  = PapdHelper.CalcSig(postData, this.textBox1.Text, GlobalContext.CurrentPfxPrivateKey, out combineStr);
                this.textBox3.Text += "\r\n";
                this.textBox3.Text += "\r\n";
                this.textBox3.Text += combineStr;
            }
            catch (Exception ex)
            {
                MessageBox.Show("计算失败," + ex.Message);
                this.textBox3.Text = combineStr;
            }
        }