C#中等效php的base64_decode函数如何写
PHP 中, base64_encode() 函数对应C#的实现为以下代码:
public static string base64_encode(string str)
{
byte[] temp1 = Encoding.UTF8.GetBytes(str);
string temp2 = Convert.ToBase64String(temp1);
return temp2;
}
想知道base64_decode()该如何实现,另看看上面代码应该没错吧
------解决方案--------------------public static string Base64Encode(string AStr)
{
return Convert.ToBase64String(Encoding.UTF8.GetBytes(AStr));
}
public static string Base64Decode(string ABase64)
{
return Encoding.UTF8.GetString(Convert.FromBase64String(ABase64));
}
private void button1_Click(object sender, EventArgs e)
{
Text = Base64Decode(Base64Encode( "Zswang 路过 "));
}