Last active
October 24, 2024 19:35
-
-
Save vortexau/13de5b6f9e46cf419f1540753c573206 to your computer and use it in GitHub Desktop.
Powershell to decompress DEFLATE data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$base64data = "insert compressed and base64 data here" | |
$data = [System.Convert]::FromBase64String($base64data) | |
$ms = New-Object System.IO.MemoryStream | |
$ms.Write($data, 0, $data.Length) | |
$ms.Seek(0,0) | Out-Null | |
$sr = New-Object System.IO.StreamReader(New-Object System.IO.Compression.DeflateStream($ms, [System.IO.Compression.CompressionMode]::Decompress)) | |
while ($line = $sr.ReadLine()) { | |
$line | |
} |
also, if you are trying to decompress things compressed by zlib, you probably want to use ZLibStream
instead of DeflateStream
. Now, if you're trying to decompress an actual ZipFile, the process is different, those are for bare streams.
Thank you @Luiz-Monad, this helped me a lot and works now.
Have a great day!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's because you're trying to decompress data compressed in another format like gzip or not compressed.
This is how you use it