测试

大憨熊 提交于 2019-11-28 14:44:52
namespace EncodeandDecode
{
    class Program
    {
        static void Main(string[] args)
        {
            byte[] bytes = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
            Console.WriteLine("The byte array: ");
            Console.WriteLine("   {0}\n", BitConverter.ToString(bytes));
            // BitConverter.ToString(bytes)是转换为16进制字符串

            string s = Convert.ToBase64String(bytes);
            //s = bytes转换成的16进制字符串再进行Base64加密而生成的字符串
            Console.WriteLine("The base 64 string: ");
            Console.WriteLine("   {0}\n", s);

            byte[] newBytes = Convert.FromBase64String(s);
            //把s还原回16进制字符串
            Console.WriteLine("The restored byte array: ");
            Console.WriteLine("   {0}\n", BitConverter.ToString(newBytes));
        }
    }
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!