/// <summary>
/// 实现Base64加密解密
/// </summary>
public sealed class Base64
{
/// <summary>
/// BASE64编码加密
/// </summary>
/// <param name="s"></param>
/// <param name="encode"></param>
/// <returns></returns>
public static string Base64Encode(string s, string encode)
{
return Convert.ToBase64String(Encoding.GetEncoding(encode).GetBytes(s));
}
/// <summary>
/// BASE64编码解密
/// </summary>
/// <param name="s"></param>
/// <param name="encode"></param>
/// <returns></returns>
public static string Base64Decode(string s, string encode)
{
return Encoding.GetEncoding(encode).GetString(Convert.FromBase64String(s));
}
}
注:encode传utf-8,s传需加密的值