标签:
C#下BASE64加密其实就一句话
static class MyBase64 { public static Encoding[] encoding = { Encoding.ASCII, Encoding.Unicode, Encoding.UTF7, Encoding.UTF8, Encoding.UTF32, Encoding.BigEndianUnicode, Encoding.GetEncoding("GB2312"), Encoding.GetEncoding("GBK") }; static public string EncodeBase64(string Base64_Message, int index) { try { return System.Convert.ToBase64String(encoding[index].GetBytes(Base64_Message)); } catch { MessageBox.Show("加密失败"); return ""; } } public static string DecodeBase64(string Base64_Ciphertext, int index) { try { return encoding[index].GetString(System.Convert.FromBase64String(Base64_Ciphertext)); } catch { MessageBox.Show("该密文不适用于该种编码"); return ""; } } }
要注意有个编码方式
标签:
原文地址:http://www.cnblogs.com/xzhblogs/p/5799064.html