45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:解决C#中Base64之编码的方法

解决C#中Base64之编码的方法

2016-09-09 09:43:30 来源:www.45fan.com 【

解决C#中Base64之编码的方法

编码

public string EncodeBase64(string code_type,string code)

{

string encode = "";

byte[] bytes = Encoding.GetEncoding(code_type).GetBytes(code);

try

{

encode = Convert.ToBase64String(bytes);

}

catch

{

encode = code;

}

return encode;

}

解码

public string DecodeBase64(string code_type,string code)

{

string decode = "";

byte[] bytes = Convert.FromBase64String(code);

try

{

decode = Encoding.GetEncoding(code_type).GetString(bytes);

}

catch

{

decode = code;

}

return decode;

}
 

本文地址:http://www.45fan.com/a/question/73934.html
Tags: 解码 Base64 编码
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部