编码字符串
代码:
public string base64Encode(string data)
{
try
{
byte[] encData_byte = new byte[data.Length];
encData_byte = System.Text.Encoding.UTF8.GetBytes(data);
string encodedData = Convert.ToBase64String(encData_byte);
return encodedData;
}
catch(Exception e)
{
throw new Exception("Error in base64Encode" + e.Message);
}
}
答案 0 :(得分:2)
public string Base64Decode(string data)
{
byte[] byteArray = Convert.FromBase64String(data);
var message = System.Text.Encoding.UTF8.GetString(byteArray);
return message;
}
答案 1 :(得分:1)
查看Convert.FromBase64String
。