Esempio n. 1
0
        /*
         * string str = "你好";
         * var buff = System.Text.Encoding.Unicode.GetBytes(str);
         * string str2 = Convert.ToBase64String(buff);//加密str2
         *                                         //=================下面是解码的部分
         * buff =Convert.FromBase64String(str2);
         *  str=System.Text.Encoding.Unicode.GetString(buff);
         */
        /// <summary>
        /// 生成请求码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click_1(object sender, EventArgs e)
        {
            try
            {
                string strendrq  = DateTime.Now.ToString("yyyy-MM-dd");
                string strRandom = NewGuid.NextRandom(10000, 1).ToString();
                string i         = this.textBox1.Text.ToString();
                string n         = this.tbx1.Text.ToString();


                if (string.IsNullOrEmpty(i))
                {
                    MessageBox.Show("请填写企业Id!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                    return;
                }

                if (string.IsNullOrEmpty(n))
                {
                    MessageBox.Show("请填写企业名称!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                    return;
                }

                var    buff = System.Text.Encoding.Unicode.GetBytes(n);
                string str2 = Convert.ToBase64String(buff);

                JsonParser.JsonRegister jsonRegister = new JsonParser.JsonRegister();
                jsonRegister.I = i;
                jsonRegister.R = strRandom;
                jsonRegister.M = GetModuleCode();
                jsonRegister.N = str2;
                jsonRegister.T = strendrq;

                var registerEntity = new JsonParser.JsonRegister
                {
                    I = EncodeBase32(jsonRegister.I.Trim()),
                    R = EncodeBase32("Y" + jsonRegister.R),
                    M = EncodeBase32(jsonRegister.M),

                    N    = EncodeBase32(jsonRegister.N),
                    T    = EncodeBase32("K" + jsonRegister.T),
                    Info = 0
                };
                string strCode = Newtonsoft.Json.JsonConvert.SerializeObject(registerEntity); //序列化成JSON
                                                                                              //string p = DecodeBase32(registerEntity.P);
                string strEncode32  = EncodeBase32(strCode);
                string strEncode    = RsaEncrypt(strEncode32);
                string strAesEncode = AesClass.AesEncrypt(strEncode);
                this.richTextBox1.Text = strAesEncode;
            }catch (Exception ex)
            {
                MessageBox.Show("操作失败!原因:" + ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 生成激活码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string strjsonRegister = this.richTextBox3.Text.ToString().Trim();

            if (strjsonRegister.Trim().Equals(string.Empty) || strjsonRegister.Length == 0)
            {
                MessageBox.Show("请选解析请求码!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                return;
            }
            string strendrq = Start_dateTimePicker.Value.ToString("yyyy-MM-dd");

            string strRandom        = NewGuid.NextRandom(10000, 1).ToString();
            JavaScriptSerializer js = new JavaScriptSerializer();

            JsonParser.JsonRegister jsonRegister = js.Deserialize <JsonParser.JsonRegister>(strjsonRegister);

            var    buff = System.Text.Encoding.Unicode.GetBytes(jsonRegister.N.ToString().Trim());
            string str2 = Convert.ToBase64String(buff);//加密str2

            jsonRegister.I = EncodeBase32(jsonRegister.I.Trim());
            jsonRegister.R = EncodeBase32("Y" + strRandom.ToString().Trim());
            jsonRegister.M = GetModuleCode();
            jsonRegister.M = EncodeBase32(jsonRegister.M);//(jsonRegister.M.ToString().Trim());

            jsonRegister.N = EncodeBase32(str2);
            jsonRegister.T = EncodeBase32(strendrq.ToString().Trim());

            JsonParser.JsonSign jsonSign = new JsonParser.JsonSign();
            jsonSign.data = jsonRegister;                                            //js.Serialize(jsonRegister).Trim(); //序列化成JSON
            string registerStortJson = StortJson(js.Serialize(jsonRegister), false); //排序

            jsonSign.sing = Sign(registerStortJson);

            string strJsonCode = js.Serialize(jsonSign).Trim();   //序列化成JSON
            //string strEncode32 = EncodeBase32(strJsonCode);
            string strEncode           = RsaEncrypt(strJsonCode); //RSAFromPkcs8.BlockEncrypt(strEncode32);//privateKey 加密
            string strAesEncode        = AesClass.AesEncrypt(strEncode);
            string strEncodeBase32Code = EncodeBase32(strAesEncode);

            this.richTextBox2.Text = strEncodeBase32Code;

            //BANLF7GEKN5MKJ7LK6SRDQIP6AJL367T6LV53Q4VYAALSSBEYNRPJ8GUYSV5UMJMCXY83IGCA67QM8BVCX7MQXJJCAMAL8JGDH7AUTJTKYULV383FTSRUXTSKYSM3TK3KT8PLTNQCI48KITTKNKAGVKJ6CAUQJGFKAF4HP4J6PTPUPGAKFSQ3PTIFPNM3INQKY7AJSKN6WT4UJN3DAAQD3B3KA3MW3BABNGUG3J3BAILWCN8ACYRD7NJUPWA38JYKFRQD8JEUTY83Q45AXR8DCVB63W56XG8CANMKMTBF3W8GJVQUT6RFXJA6YHRKBVE6AS4LIVSKPRQ9I4QBYW5GC74YA8GQIGKDXQMMD4EUATUVIKUCTCAD74AYP7RMQ86FXXUDQ4IFTBQLJJ4FIYR6TYSFXFQUWVAFCUAJ6TICY8RDMKFKPTLQSBNENA8LTJQEYIMW874UC4UFPYIAXT86XTTYT58G6BLENJADP4P6IBMKQ4SEAWRDKTEBYR83TTJYY5MQVJAYX4LVWYIDPJR63ISUXA5DTBK6CLUM6KEUI7MU8Y3FIPMF8JD6IFMSCJUUTBADXJNKXGUKI4A6CTPUDBCCY8QFJ78UTTL6XVI6ISMQXIPCNQA6Q4JUTPQWX8JKYPPHQY36WSUDSJEEAMPM745YN6AK385FI44K8VYKIVPJ7I3CC85GDBEUNI8KDGUDP4LDT46YMVMM7KKFTHP38KQYY5U99YPKIV4GMGYKTUQD3KVYNGP367CAX8A66856TWM9X8TUAUR6WJCYIJMFCJIUP78GWNMKH7L37G5ACQU3JKS6C7G9PBMCIAL3CGRCCHRUSB36CR8GCKNEAVMWSKICCV8UKTSBAVQFK7RUTA568NSCTKAD3JMDYRQ3I74AXQ5UTIEKCFPMS7FYYK5UPVVKY44LI8FKXP4L3YIFI7MVWNPYWVMD8V6UPI8KXBGCNVLK9KRKIWR6WITFASMV9K3FANMDP8DDY7M68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