/// <summary> /// Base64编码 /// </summary> /// <param name="str">字符串</param> /// <returns></returns> public string StringToBase64(string str) { var bytes = System.Text.Encoding.UTF8.GetBytes(str); return Convert.ToBase64String(bytes); } /// <summary> /// Base64解码 /// </summary> /// <param name="str">字符串</param> /// <returns></returns> public string Base64ToString(string str) { var outputb = Convert.FromBase64String(str); return System.Text.Encoding.UTF8.GetString(outputb); }
时间: 2024-11-13 08:21:28