示例#1
0
        private void button21_Click(object sender, EventArgs e)//URL二次部分编码
        {
            Encoding encoding = Encoding.ASCII;
            int      t        = comboBox4.SelectedIndex;

            switch (t)
            {
            case 0: encoding = Encoding.UTF8; break;

            case 1: encoding = Encoding.GetEncoding("GB2312"); break;

            case 2: encoding = Encoding.GetEncoding("GBK"); break;

            case 3: encoding = Encoding.ASCII; break;

            case 4: encoding = Encoding.Unicode; break;

            case 5: encoding = Encoding.UTF7; break;

            case 6: encoding = Encoding.UTF32; break;

            case 7: encoding = Encoding.BigEndianUnicode; break;

            default: encoding = Encoding.UTF8; break;
            }
            richTextBox6.Text = MyUrl.Encode(MyUrl.Encode(richTextBox5.Text, encoding), encoding);
        }
示例#2
0
        private void button14_Click(object sender, EventArgs e)//Base64解密
        {
            Encoding encoding = Encoding.UTF8;

            int t = comboBox1.SelectedIndex;

            switch (t)
            {
            case 0: encoding = Encoding.UTF8; break;

            case 1: encoding = Encoding.GetEncoding("GB2312"); break;

            case 2: encoding = Encoding.GetEncoding("GBK"); break;

            case 3: encoding = Encoding.ASCII; break;

            case 4: encoding = Encoding.Unicode; break;

            case 5: encoding = Encoding.UTF7; break;

            case 6: encoding = Encoding.UTF32; break;

            case 7: encoding = Encoding.BigEndianUnicode; break;

            default: encoding = Encoding.UTF8; break;
            }

            string decode_Num = textBox14.Text;
            int    num        = 1;

            int.TryParse(decode_Num, out num);
            if (num < 1)
            {
                num = 1;
            }

            bool   url_decode_flag   = checkBox1.Checked;
            string Base64_Ciphertext = richTextBox14.Text;

            for (int i = 0; i < num; i++)
            {
                if (url_decode_flag)
                {
                    Base64_Ciphertext = MyUrl.Decode(Base64_Ciphertext, encoding);
                }
                Base64_Ciphertext = MyBase64.DecodeBase64(Base64_Ciphertext, encoding);
            }

            richTextBox13.Text = Base64_Ciphertext;
        }