首页 > 其他 > 详细

Base64加密和解密方式

时间:2020-07-03 10:24:01      阅读:69      评论:0      收藏:0      [点我收藏+]

public class Base64
{
///编码  code_type  编码方式(UTF-8),code 编码内容
public static string EncodeBase64(string code_type, string code)
{
string encode = "";
byte[] bytes = Encoding.GetEncoding(code_type).GetBytes(code);
try
{
encode = Convert.ToBase64String(bytes);
}
catch
{
encode = code;
}
return encode;
}
///解码  code_type  编码方式(UTF-8),code  解码内容
public static string DecodeBase64(string code_type, string code)
{
string decode = "";
byte[] bytes = Convert.FromBase64String(code);
try
{
decode = Encoding.GetEncoding(code_type).GetString(bytes);
}
catch
{
decode = code;
}
return decode;
}
}

Base64加密和解密方式

原文:https://www.cnblogs.com/AbelAngelo/p/13228566.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!