字符串压缩与解压缩
源码:
/// 字符串压缩 public static string CompressString(string str) { string compressString = ""; byte[] compressBeforeByte = Encoding.UTF8.GetBytes(str); byte[] compressAfterByte = Compress(compressBeforeByte); //compressString = Encoding.GetEncoding("UTF-8").GetString(compressAfterByte); compressString = Convert.ToBase64String(compressAfterByte); return compressString; } /// 字符串解压缩 public static string DecompressString(string str) { string compressString = ""; //byte[] compressBeforeByte = Encoding.GetEncoding("UTF-8").GetBytes(str); byte[] compressBeforeByte = Convert.FromBase64String(str); byte[] compressAfterByte = Decompress(compressBeforeByte); compressString = Encoding.UTF8.GetString(compressAfterByte); return compressString; }