public static string Zip(string value)
{
byte[] byteArray = Encoding.UTF8.GetBytes(value);
byte[] tmpArray;
using (MemoryStream ms = new MemoryStream())
{
using (zlib.ZOutputStream outZStream = new zlib.ZOutputStream(ms, zlib.zlibConst.Z_DEFAULT_COMPRESSION))
{
outZStream.Write(byteArray, 0, byteArray.Length);
outZStream.Flush();
}
tmpArray = ms.ToArray();
}
return Convert.ToBase64String(tmpArray);
}
c#利用zlib.net对string进行压缩(与java程序生成结果对应)
最新推荐文章于 2024-07-27 08:00:00 发布