Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. public static string decompressText(string compressedText)
  2. {
  3. compressedText = compressedText.Replace("uFEFF", "");
  4. //compressedText = "CQAAAB+LCAAAAAAABABzzs/LS00uSU0BABaaRpgJAAAA";
  5. byte[] gzBuffer = Convert.FromBase64String(compressedText);
  6. using (MemoryStream ms = new MemoryStream())
  7. {
  8. int msgLength = BitConverter.ToInt32(gzBuffer, 0);
  9. ms.Write(gzBuffer, 4, gzBuffer.Length - 4);
  10.  
  11. byte[] buffer = new byte[msgLength];
  12. ms.Position = 0;
  13. using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
  14. {
  15. zip.Read(buffer, 0, buffer.Length);
  16. }
  17. return Encoding.UTF8.GetString(buffer);
  18. }
  19. }
  20.  
  21. <!DOCTYPE html>
  22. <head>
  23. <script src="path_to/some_compression_decompression.js"></script>
  24. <script>
  25. var text = 'compressedData';
  26. var libObj = new some_compression_decompression_class();
  27. console.log(libObj.decompress(text)); // output decompressed data
  28. </script>
  29. <head>
  30. <body>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement