Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string decompressText(string compressedText)
- {
- compressedText = compressedText.Replace("uFEFF", "");
- //compressedText = "CQAAAB+LCAAAAAAABABzzs/LS00uSU0BABaaRpgJAAAA";
- byte[] gzBuffer = Convert.FromBase64String(compressedText);
- using (MemoryStream ms = new MemoryStream())
- {
- int msgLength = BitConverter.ToInt32(gzBuffer, 0);
- ms.Write(gzBuffer, 4, gzBuffer.Length - 4);
- byte[] buffer = new byte[msgLength];
- ms.Position = 0;
- using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
- {
- zip.Read(buffer, 0, buffer.Length);
- }
- return Encoding.UTF8.GetString(buffer);
- }
- }
- <!DOCTYPE html>
- <head>
- <script src="path_to/some_compression_decompression.js"></script>
- <script>
- var text = 'compressedData';
- var libObj = new some_compression_decompression_class();
- console.log(libObj.decompress(text)); // output decompressed data
- </script>
- <head>
- <body>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement