C#.NET实现Base64解密/加密

using System;
using System.Collections.Generic;
using System.Text;

namespace Base64Test
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputText = "This is some text.";
            Console.Out.WriteLine("Input text: {0}", inputText);
            byte[] bytesToEncode = Encoding.UTF8.GetBytes(inputText);

            string encodedText = Convert.ToBase64String(bytesToEncode);
            Console.Out.WriteLine("Encoded text: {0}", encodedText);

            byte[] decodedBytes = Convert.FromBase64String(encodedText);
            string decodedText = Encoding.UTF8.GetString(decodedBytes);
            Console.Out.WriteLine("Decoded text: {0}", decodedText);

            Console.Out.Write("Press enter to finish.");
            Console.In.ReadLine();

            return;
        }
    }
}

CSharp代理Post网页

        public string GetPostString(string url, string data,string proxyip,int proxyport)
        {
            try
            {
                byte[] postBytes = Encoding.GetEncoding("utf-8").GetBytes(data);
                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
                myRequest.Method = "POST";
                myRequest.ContentType = "text/html";
                myRequest.ContentLength = postBytes.Length;
                System.Net.WebProxy proxy = new WebProxy(proxyip, proxyport);
                myRequest.Proxy = proxy;
                Stream newStream = myRequest.GetRequestStream();
                newStream.Write(postBytes, 0, postBytes.Length);
                newStream.Close();
                // Get response
                HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                using (StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("utf-8")))
                {
                    string content = reader.ReadToEnd();
                    return content;
                }
            }
            catch (System.Exception ex)
            {
                return ex.Message;
            }
        }


使用方法:

            string str;
            str = GetPostString("http://ip.chinaz.com/", @"password=abc","127.0.0.1",8080);
            textBox1.Text = str;