C#中最简单Base64加密解密支持中文的函数方法(UTF8)

之前微软官方找了一段Base64加密解密的方法,发现不支持中文,我想应该是UTF8形式的Base64应该可以支持中文,于是找到了这个最简单Base64加密解密的方法,再次收藏一下:

public string Encode(string str)
{
   byte[] encbuff = System.Text.Encoding.UTF8.GetBytes(str);
   return Convert.ToBase64String(encbuff);
}
 
public string Decode(string str)
{
   byte[] decbuff = Convert.FromBase64String(str);
   return System.Text.Encoding.UTF8.GetString(decbuff);
}

引用通告地址: 点击获取引用地址
标签: C#
评论: 0 | 引用: 0 | 阅读: 1510 | 打印 | 打包 | 转发
发表评论
昵 称: 密 码:
网 址: 邮 箱:
验证码: 验证码图片 选 项:
头 像:
内 容:
  • 粗体
  • 斜体
  • 下划线
  • 插入图像
  • 超链接
  • 电子邮件
  • 插入引用