base64编码和解码

string Str = "abc";

// 编码
string BaseStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(Str));

Console.WriteLine(BaseStr);// YWJj

// 解码
string OldStr = Encoding.GetEncoding("utf-8").GetString(Convert.FromBase64String(BaseStr));

Console.WriteLine(OldStr); // abc

 

posted @ 2014-11-10 17:41  幸福就好  阅读(139)  评论(0编辑  收藏  举报