-
Notifications
You must be signed in to change notification settings - Fork 1
/
GZip.cs
35 lines (33 loc) · 986 Bytes
/
GZip.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ERSaveManager
{
public class GZip
{
public static byte[] compress(byte[] data)
{
using (var output = new MemoryStream())
{
using (var gzip = new GZipStream(output, CompressionMode.Compress))
using (var source = new MemoryStream(data))
source.CopyTo(gzip);
return output.ToArray();
}
}
public static byte[] decompress(byte[] compressed)
{
using (var source = new MemoryStream(compressed))
using (var gzip = new GZipStream(source, CompressionMode.Decompress))
using (var output = new MemoryStream())
{
gzip.CopyTo(output);
return output.ToArray();
}
}
}
}