需要引入命名空间:
using System;
using System.Text;
public static string UnBase64String(string value)
{
if (value == null || value == "")
{
return "";
}
byte[] bytes = Convert.FromBase64String(value);
return Encoding.UTF8.GetString(bytes);
}
public static string ToBase64String(string value)
{
if (value == null || value == "")
{
return "";
}
byte[] bytes = Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(bytes);
}
测试:
public static void Base64Test(){
string base64string = GameCommon.ToBase