试了几种方式后面不会带等于号,记录一下 /// summary /// Base64编码,采用utf8编码 /// /summary /// param name="strPath"待编码的明文/param /// returnsBase64编码后的字符串/returns public static string Base
试了几种方式后面不会带等于号,记录一下
/// <summary>
/// Base64编码,采用utf8编码
/// </summary>
/// <param name="strPath">待编码的明文</param>
/// <returns>Base64编码后的字符串</returns>
public static string Base64Encrypt(string strPath)
{
string returnData;
Encoding encode = Encoding.UTF8;
byte[] bytedata = encode.GetBytes(strPath);
try
{
returnData = Convert.ToBase64String(bytedata, 0, bytedata.Length);
}
catch
{
returnData = strPath;
}
return returnData;
}
/// <summary>
/// Base64解码,采用utf8编码方式解码
/// </summary>
/// <param name="strPath">待解码的密文</param>
/// <returns>Base64解码的明文字符串</returns>
public static string Base64DesEncrypt(string strPath)
{
string returnData;
byte[] bpath = Convert.FromBase64String(strPath);
try
{
returnData = Encoding.UTF8.GetString(bpath);
}
catch
{
returnData = strPath;
}
return returnData;
}
【本文来源:韩国服务器 http://www.558idc.com/kt.html欢迎留下您的宝贵建议】