C#中base64编码与解码

public static string b64decode(string s)//b64解码
{

    byte[] outputb = Convert.FromBase64String(s);
    return Encoding.Default.GetString(outputb);
}
public static string b64encode(string s)//b64编码
{
    System.Text.Encoding encode = System.Text.Encoding.ASCII;
    byte[]  bytedata = encode.GetBytes(s);
    return  Convert.ToBase64String(bytedata,0,bytedata.Length);
}

你可能感兴趣的:(C#)