You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
694 B

2 years ago
  1. using System.IO;
  2. namespace EasyBL.WebApi.Helper
  3. {
  4. public class CompressionHelper
  5. {
  6. public static byte[] DeflateByte(byte[] str)
  7. {
  8. if (str == null)
  9. {
  10. return null;
  11. }
  12. using (var output = new MemoryStream())
  13. {
  14. using (
  15. var compressor = new Ionic.Zlib.DeflateStream(
  16. output, Ionic.Zlib.CompressionMode.Compress,
  17. Ionic.Zlib.CompressionLevel.BestSpeed))
  18. {
  19. compressor.Write(str, 0, str.Length);
  20. }
  21. return output.ToArray();
  22. }
  23. }
  24. }
  25. }