字符串转Base64编码(互转)
1.字符串转Base64编码/// <summary>
/// 字符串转Base64编码
/// </summary>
/// <param name="Context">需要加密的内容</param>
/// <returns></returns>
public static string EncryptionBase64Context(string context)
{
byte[] byteArray = System.Text.Encoding.Default.GetBytes(context);
string content = Convert.ToBase64String(byteArray);
return content;
}
2.Base64转字符串
/// <summary>
/// Base64转字符串
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public static string DecryptionBase64Context(string context)
{
byte[] output = Convert.FromBase64String(context);
string orgStr = Encoding.Default.GetString(output);
return orgStr;
}
谢谢分享,学习学习
页:
[1]