现在的位置: 首页 > 综合 > 正文

BASE64的编码解码

2012年03月26日 ⁄ 综合 ⁄ 共 515字 ⁄ 字号 评论关闭
//base64编码
            string strBase = "hello world";
            
byte[] bytStr = System.Text.Encoding.Default.GetBytes(strBase);
            
string strBase64 = Convert.ToBase64String(bytStr);
            Console.WriteLine(
"strBase64:{0} length:{1}",strBase64,strBase64.Length);
            
//base解吗
            byte[] byts = Convert.FromBase64String(strBase64);
            
string strSource = System.Text.Encoding.Default.GetString(byts);
            Console.WriteLine(
"source:{0} lenght:{1}",strSource,strSource.Length);

抱歉!评论已关闭.